make the loader keep a SwfdecAsValue, not target_movie/target_string
[swfdec.git] / vivified / core / vivi_player_as.c
blobf2d79e8a1f5c334834c6dd5800102a6d55ec49d9
1 /* Vivified
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "vivi_wrap.h"
25 #include "vivi_application.h"
26 #include "vivi_function.h"
27 #include <swfdec-gtk/swfdec-gtk.h>
29 VIVI_FUNCTION ("player_frame_get", vivi_player_as_frame_get)
30 void
31 vivi_player_as_frame_get (SwfdecAsContext *cx, SwfdecAsObject *this,
32 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
34 ViviApplication *app = VIVI_APPLICATION (cx);
35 SwfdecAsObject *obj;
37 obj = SWFDEC_AS_OBJECT (swfdec_as_context_get_frame (SWFDEC_AS_CONTEXT (app->player)));
38 if (obj)
39 SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (app, obj));
42 VIVI_FUNCTION ("player_filename_get", vivi_player_as_filename_get)
43 void
44 vivi_player_as_filename_get (SwfdecAsContext *cx, SwfdecAsObject *this,
45 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
47 ViviApplication *app = VIVI_APPLICATION (cx);
48 const char *s = vivi_application_get_filename (app);
50 if (s)
51 SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
54 VIVI_FUNCTION ("player_filename_set", vivi_player_as_filename_set)
55 void
56 vivi_player_as_filename_set (SwfdecAsContext *cx, SwfdecAsObject *this,
57 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
59 ViviApplication *app = VIVI_APPLICATION (cx);
60 const char *s;
62 if (argc == 0)
63 return;
64 s = swfdec_as_value_to_string (cx, &argv[0]);
66 vivi_application_set_filename (app, s);
69 VIVI_FUNCTION ("player_variables_get", vivi_player_as_variables_get)
70 void
71 vivi_player_as_variables_get (SwfdecAsContext *cx, SwfdecAsObject *this,
72 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
74 ViviApplication *app = VIVI_APPLICATION (cx);
75 const char *s = vivi_application_get_variables (app);
77 if (s)
78 SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
81 VIVI_FUNCTION ("player_variables_set", vivi_player_as_variables_set)
82 void
83 vivi_player_as_variables_set (SwfdecAsContext *cx, SwfdecAsObject *this,
84 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
86 ViviApplication *app = VIVI_APPLICATION (cx);
87 const char *s;
89 if (argc == 0)
90 return;
91 s = swfdec_as_value_to_string (cx, &argv[0]);
93 vivi_application_set_variables (app, s);
96 VIVI_FUNCTION ("player_global_get", vivi_player_as_global_get)
97 void
98 vivi_player_as_global_get (SwfdecAsContext *cx, SwfdecAsObject *this,
99 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
101 ViviApplication *app = VIVI_APPLICATION (cx);
103 if (SWFDEC_AS_CONTEXT (app->player)->global) {
104 SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (app,
105 SWFDEC_AS_CONTEXT (app->player)->global));
109 VIVI_FUNCTION ("player_sound_get", vivi_player_as_sound_get)
110 void
111 vivi_player_as_sound_get (SwfdecAsContext *cx, SwfdecAsObject *this,
112 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
114 ViviApplication *app = VIVI_APPLICATION (cx);
116 SWFDEC_AS_VALUE_SET_BOOLEAN (retval,
117 swfdec_gtk_player_get_audio_enabled (SWFDEC_GTK_PLAYER (app->player)));
120 VIVI_FUNCTION ("player_sound_set", vivi_player_as_sound_set)
121 void
122 vivi_player_as_sound_set (SwfdecAsContext *cx, SwfdecAsObject *this,
123 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
125 ViviApplication *app = VIVI_APPLICATION (cx);
127 if (argc == 0)
128 return;
129 swfdec_gtk_player_set_audio_enabled (SWFDEC_GTK_PLAYER (app->player),
130 swfdec_as_value_to_boolean (cx, &argv[0]));