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.
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
24 #include "swfdec_video.h"
25 #include "swfdec_as_internal.h"
26 #include "swfdec_as_strings.h"
27 #include "swfdec_debug.h"
28 #include "swfdec_internal.h"
29 #include "swfdec_net_stream.h"
30 #include "swfdec_player_internal.h"
31 #include "swfdec_sandbox.h"
33 SWFDEC_AS_NATIVE (667, 1, swfdec_video_attach_video
)
35 swfdec_video_attach_video (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
36 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
38 SwfdecVideoMovie
*video
;
41 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE
, &video
, "O", &o
);
43 if (!SWFDEC_IS_VIDEO_PROVIDER (o
)) {
44 SWFDEC_WARNING ("calling attachVideo without a NetStream object");
45 swfdec_video_movie_set_provider (video
, NULL
);
49 swfdec_video_movie_set_provider (video
, SWFDEC_VIDEO_PROVIDER (o
));
52 SWFDEC_AS_NATIVE (667, 2, swfdec_video_clear
)
54 swfdec_video_clear (SwfdecAsContext
*cx
, SwfdecAsObject
*object
, guint argc
,
55 SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
57 SwfdecVideoMovie
*video
;
59 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE
, &video
, "");
61 swfdec_video_movie_clear (video
);
65 swfdec_video_movie_init_context (SwfdecPlayer
*player
)
67 SwfdecAsContext
*context
;
68 SwfdecAsObject
*video
, *proto
;
71 g_return_if_fail (SWFDEC_IS_PLAYER (player
));
73 context
= SWFDEC_AS_CONTEXT (player
);
74 video
= SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context
->global
,
75 SWFDEC_AS_STR_Video
, NULL
));
76 SWFDEC_SANDBOX (context
->global
)->Video
= video
;
77 proto
= swfdec_as_object_new_empty (context
);
78 /* set the right properties on the Video object */
79 SWFDEC_AS_VALUE_SET_OBJECT (&val
, proto
);
80 swfdec_as_object_set_variable_and_flags (video
, SWFDEC_AS_STR_prototype
, &val
,
81 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_PERMANENT
);
82 /* set the right properties on the Video.prototype object */
83 SWFDEC_AS_VALUE_SET_OBJECT (&val
, video
);
84 swfdec_as_object_set_variable_and_flags (proto
, SWFDEC_AS_STR_constructor
,
85 &val
, SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_PERMANENT
);
86 SWFDEC_AS_VALUE_SET_OBJECT (&val
, context
->Object_prototype
);
87 swfdec_as_object_set_variable_and_flags (proto
, SWFDEC_AS_STR___proto__
, &val
,
88 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_PERMANENT
);