1 /*****************************************************************************
2 * npolibvlc.cpp: official Javascript APIs
3 *****************************************************************************
4 * Copyright (C) 2002-2009 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7 * JP Dinger <jpd@m2x.nl>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
31 #ifdef HAVE_MOZILLA_CONFIG_H
32 # include <mozilla-config.h>
35 #include "vlcplugin.h"
36 #include "npolibvlc.h"
39 ** Local helper macros and function
41 #define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
42 #define RETURN_ON_EXCEPTION(this,ex) \
43 do { if( libvlc_exception_raised(&ex) ) \
45 NPN_SetException(this, libvlc_errmsg()); \
46 libvlc_exception_clear(&ex); \
47 return INVOKERESULT_GENERIC_ERROR; \
51 ** implementation of libvlc root object
54 LibvlcRootNPObject::~LibvlcRootNPObject()
57 ** When the plugin is destroyed, firefox takes it upon itself to
58 ** destroy all 'live' script objects and ignores refcounting.
59 ** Therefore we cannot safely assume that refcounting will control
60 ** lifespan of objects. Hence they are only lazily created on
61 ** request, so that firefox can take ownership, and are not released
62 ** when the plugin is destroyed.
66 if( audioObj ) NPN_ReleaseObject(audioObj);
67 if( inputObj ) NPN_ReleaseObject(inputObj);
68 if( playlistObj ) NPN_ReleaseObject(playlistObj);
69 if( videoObj ) NPN_ReleaseObject(videoObj);
73 const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
82 COUNTNAMES(LibvlcRootNPObject,propertyCount,propertyNames);
84 enum LibvlcRootNPObjectPropertyIds
94 RuntimeNPObject::InvokeResult
95 LibvlcRootNPObject::getProperty(int index, NPVariant &result)
97 /* is plugin still running */
98 if( isPluginRunning() )
103 // create child object in lazyman fashion to avoid
104 // ownership problem with firefox
106 audioObj = NPN_CreateObject(_instance,
107 RuntimeNPClass<LibvlcAudioNPObject>::getClass());
108 OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
109 return INVOKERESULT_NO_ERROR;
111 // create child object in lazyman fashion to avoid
112 // ownership problem with firefox
114 inputObj = NPN_CreateObject(_instance,
115 RuntimeNPClass<LibvlcInputNPObject>::getClass());
116 OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
117 return INVOKERESULT_NO_ERROR;
118 case ID_root_playlist:
119 // create child object in lazyman fashion to avoid
120 // ownership problem with firefox
122 playlistObj = NPN_CreateObject(_instance,
123 RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
124 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
125 return INVOKERESULT_NO_ERROR;
126 case ID_root_subtitle:
127 // create child object in lazyman fashion to avoid
128 // ownership problem with firefox
130 subtitleObj = NPN_CreateObject(_instance,
131 RuntimeNPClass<LibvlcSubtitleNPObject>::getClass());
132 OBJECT_TO_NPVARIANT(NPN_RetainObject(subtitleObj), result);
133 return INVOKERESULT_NO_ERROR;
135 // create child object in lazyman fashion to avoid
136 // ownership problem with firefox
138 videoObj = NPN_CreateObject(_instance,
139 RuntimeNPClass<LibvlcVideoNPObject>::getClass());
140 OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
141 return INVOKERESULT_NO_ERROR;
142 case ID_root_VersionInfo:
143 return invokeResultString(libvlc_get_version(),result);
148 return INVOKERESULT_GENERIC_ERROR;
151 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =
155 COUNTNAMES(LibvlcRootNPObject,methodCount,methodNames);
157 enum LibvlcRootNPObjectMethodIds
162 RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
163 const NPVariant *args, uint32_t argCount, NPVariant &result)
165 /* is plugin still running */
166 if( isPluginRunning() )
168 libvlc_exception_t ex;
169 libvlc_exception_init(&ex);
173 case ID_root_versionInfo:
175 return INVOKERESULT_NO_SUCH_METHOD;
176 return invokeResultString(libvlc_get_version(),result);
181 return INVOKERESULT_GENERIC_ERROR;
185 ** implementation of libvlc audio object
188 const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
196 COUNTNAMES(LibvlcAudioNPObject,propertyCount,propertyNames);
198 enum LibvlcAudioNPObjectPropertyIds
207 RuntimeNPObject::InvokeResult
208 LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
210 /* is plugin still running */
211 if( isPluginRunning() )
213 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
214 libvlc_exception_t ex;
215 libvlc_exception_init(&ex);
221 bool muted = libvlc_audio_get_mute(p_plugin->getVLC());
222 BOOLEAN_TO_NPVARIANT(muted, result);
223 return INVOKERESULT_NO_ERROR;
225 case ID_audio_volume:
227 int volume = libvlc_audio_get_volume(p_plugin->getVLC());
228 INT32_TO_NPVARIANT(volume, result);
229 return INVOKERESULT_NO_ERROR;
233 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
234 RETURN_ON_EXCEPTION(this,ex);
235 int track = libvlc_audio_get_track(p_md, &ex);
236 RETURN_ON_EXCEPTION(this,ex);
237 INT32_TO_NPVARIANT(track, result);
238 return INVOKERESULT_NO_ERROR;
242 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
243 RETURN_ON_EXCEPTION(this,ex);
244 // get the number of audio track available
245 int i_track = libvlc_audio_get_track_count(p_md, &ex);
246 RETURN_ON_EXCEPTION(this,ex);
248 INT32_TO_NPVARIANT(i_track, result);
249 return INVOKERESULT_NO_ERROR;
251 case ID_audio_channel:
253 int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
254 RETURN_ON_EXCEPTION(this,ex);
255 INT32_TO_NPVARIANT(channel, result);
256 return INVOKERESULT_NO_ERROR;
262 return INVOKERESULT_GENERIC_ERROR;
265 RuntimeNPObject::InvokeResult
266 LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
268 /* is plugin still running */
269 if( isPluginRunning() )
271 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
272 libvlc_exception_t ex;
273 libvlc_exception_init(&ex);
278 if( NPVARIANT_IS_BOOLEAN(value) )
280 libvlc_audio_set_mute(p_plugin->getVLC(),
281 NPVARIANT_TO_BOOLEAN(value));
282 return INVOKERESULT_NO_ERROR;
284 return INVOKERESULT_INVALID_VALUE;
285 case ID_audio_volume:
286 if( isNumberValue(value) )
288 libvlc_audio_set_volume(p_plugin->getVLC(),
289 numberValue(value), &ex);
290 RETURN_ON_EXCEPTION(this,ex);
291 return INVOKERESULT_NO_ERROR;
293 return INVOKERESULT_INVALID_VALUE;
295 if( isNumberValue(value) )
297 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
298 RETURN_ON_EXCEPTION(this,ex);
299 libvlc_audio_set_track(p_md, numberValue(value), &ex);
300 RETURN_ON_EXCEPTION(this,ex);
301 return INVOKERESULT_NO_ERROR;
303 return INVOKERESULT_INVALID_VALUE;
304 case ID_audio_channel:
305 if( isNumberValue(value) )
307 libvlc_audio_set_channel(p_plugin->getVLC(),
308 numberValue(value), &ex);
309 RETURN_ON_EXCEPTION(this,ex);
310 return INVOKERESULT_NO_ERROR;
312 return INVOKERESULT_INVALID_VALUE;
317 return INVOKERESULT_GENERIC_ERROR;
320 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
325 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
327 enum LibvlcAudioNPObjectMethodIds
330 ID_audio_description,
333 RuntimeNPObject::InvokeResult
334 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
335 uint32_t argCount, NPVariant &result)
337 /* is plugin still running */
338 if( isPluginRunning() )
340 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
341 libvlc_exception_t ex;
342 libvlc_exception_init(&ex);
346 case ID_audio_togglemute:
349 libvlc_audio_toggle_mute(p_plugin->getVLC());
350 VOID_TO_NPVARIANT(result);
351 return INVOKERESULT_NO_ERROR;
353 return INVOKERESULT_NO_SUCH_METHOD;
354 case ID_audio_description:
359 int i_trackID, i_limit, i;
360 libvlc_track_description_t *p_trackDesc;
362 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
363 RETURN_ON_EXCEPTION(this,ex);
365 /* get tracks description */
366 p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
367 RETURN_ON_EXCEPTION(this,ex);
369 return INVOKERESULT_GENERIC_ERROR;
371 /* get the number of track available */
372 i_limit = libvlc_audio_get_track_count(p_md, &ex);
373 RETURN_ON_EXCEPTION(this,ex);
375 /* check if a number is given by the user
376 * and get the track number */
377 if( isNumberValue(args[0]) )
378 i_trackID = numberValue(args[0]);
380 return INVOKERESULT_INVALID_VALUE;
382 /* if bad number is given return invalid value */
383 if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) )
384 return INVOKERESULT_INVALID_VALUE;
386 /* get the good trackDesc */
387 for( i = 0 ; i < i_trackID ; i++ )
389 p_trackDesc = p_trackDesc->p_next;
391 psz_name = p_trackDesc->psz_name;
393 /* display the name of the track chosen */
394 return invokeResultString( psz_name, result );
396 return INVOKERESULT_NO_SUCH_METHOD;
402 return INVOKERESULT_GENERIC_ERROR;
406 ** implementation of libvlc input object
409 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
419 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
421 enum LibvlcInputNPObjectPropertyIds
432 RuntimeNPObject::InvokeResult
433 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
435 /* is plugin still running */
436 if( isPluginRunning() )
438 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
439 libvlc_exception_t ex;
440 libvlc_exception_init(&ex);
442 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
443 if( libvlc_exception_raised(&ex) )
445 if( index != ID_input_state )
447 NPN_SetException(this, libvlc_errmsg());
448 libvlc_exception_clear(&ex);
449 return INVOKERESULT_GENERIC_ERROR;
453 /* for input state, return CLOSED rather than an exception */
454 INT32_TO_NPVARIANT(0, result);
455 libvlc_exception_clear(&ex);
456 return INVOKERESULT_NO_ERROR;
462 case ID_input_length:
464 double val = (double)libvlc_media_player_get_length(p_md, &ex);
465 RETURN_ON_EXCEPTION(this,ex);
466 DOUBLE_TO_NPVARIANT(val, result);
467 return INVOKERESULT_NO_ERROR;
469 case ID_input_position:
471 double val = libvlc_media_player_get_position(p_md, &ex);
472 RETURN_ON_EXCEPTION(this,ex);
473 DOUBLE_TO_NPVARIANT(val, result);
474 return INVOKERESULT_NO_ERROR;
478 double val = (double)libvlc_media_player_get_time(p_md, &ex);
479 RETURN_ON_EXCEPTION(this,ex);
480 DOUBLE_TO_NPVARIANT(val, result);
481 return INVOKERESULT_NO_ERROR;
485 int val = libvlc_media_player_get_state(p_md, &ex);
486 RETURN_ON_EXCEPTION(this,ex);
487 INT32_TO_NPVARIANT(val, result);
488 return INVOKERESULT_NO_ERROR;
492 float val = libvlc_media_player_get_rate(p_md, &ex);
493 RETURN_ON_EXCEPTION(this,ex);
494 DOUBLE_TO_NPVARIANT(val, result);
495 return INVOKERESULT_NO_ERROR;
499 double val = libvlc_media_player_get_fps(p_md, &ex);
500 RETURN_ON_EXCEPTION(this,ex);
501 DOUBLE_TO_NPVARIANT(val, result);
502 return INVOKERESULT_NO_ERROR;
504 case ID_input_hasvout:
506 bool val = p_plugin->player_has_vout(&ex);
507 RETURN_ON_EXCEPTION(this,ex);
508 BOOLEAN_TO_NPVARIANT(val, result);
509 return INVOKERESULT_NO_ERROR;
515 return INVOKERESULT_GENERIC_ERROR;
518 RuntimeNPObject::InvokeResult
519 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
521 /* is plugin still running */
522 if( isPluginRunning() )
524 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
525 libvlc_exception_t ex;
526 libvlc_exception_init(&ex);
528 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
529 RETURN_ON_EXCEPTION(this,ex);
533 case ID_input_position:
535 if( ! NPVARIANT_IS_DOUBLE(value) )
537 return INVOKERESULT_INVALID_VALUE;
540 float val = (float)NPVARIANT_TO_DOUBLE(value);
541 libvlc_media_player_set_position(p_md, val, &ex);
542 RETURN_ON_EXCEPTION(this,ex);
543 return INVOKERESULT_NO_ERROR;
548 if( NPVARIANT_IS_INT32(value) )
549 val = (int64_t)NPVARIANT_TO_INT32(value);
550 else if( NPVARIANT_IS_DOUBLE(value) )
551 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
554 return INVOKERESULT_INVALID_VALUE;
557 libvlc_media_player_set_time(p_md, val, &ex);
558 RETURN_ON_EXCEPTION(this,ex);
559 return INVOKERESULT_NO_ERROR;
564 if( NPVARIANT_IS_INT32(value) )
565 val = (float)NPVARIANT_TO_INT32(value);
566 else if( NPVARIANT_IS_DOUBLE(value) )
567 val = (float)NPVARIANT_TO_DOUBLE(value);
570 return INVOKERESULT_INVALID_VALUE;
573 libvlc_media_player_set_rate(p_md, val, &ex);
574 RETURN_ON_EXCEPTION(this,ex);
575 return INVOKERESULT_NO_ERROR;
581 return INVOKERESULT_GENERIC_ERROR;
584 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
589 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
591 enum LibvlcInputNPObjectMethodIds
596 RuntimeNPObject::InvokeResult
597 LibvlcInputNPObject::invoke(int index, const NPVariant *args,
598 uint32_t argCount, NPVariant &result)
600 /* is plugin still running */
601 if( isPluginRunning() )
606 return INVOKERESULT_NO_SUCH_METHOD;
611 return INVOKERESULT_GENERIC_ERROR;
615 ** implementation of libvlc playlist items object
618 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
622 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
624 enum LibvlcPlaylistItemsNPObjectPropertyIds
626 ID_playlistitems_count,
629 RuntimeNPObject::InvokeResult
630 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
632 /* is plugin still running */
633 if( isPluginRunning() )
635 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
636 libvlc_exception_t ex;
637 libvlc_exception_init(&ex);
641 case ID_playlistitems_count:
643 int val = p_plugin->playlist_count(&ex);
644 RETURN_ON_EXCEPTION(this,ex);
645 INT32_TO_NPVARIANT(val, result);
646 return INVOKERESULT_NO_ERROR;
652 return INVOKERESULT_GENERIC_ERROR;
655 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
660 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
662 enum LibvlcPlaylistItemsNPObjectMethodIds
664 ID_playlistitems_clear,
665 ID_playlistitems_remove,
668 RuntimeNPObject::InvokeResult
669 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
670 uint32_t argCount, NPVariant &result)
672 /* is plugin still running */
673 if( isPluginRunning() )
675 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
676 libvlc_exception_t ex;
677 libvlc_exception_init(&ex);
681 case ID_playlistitems_clear:
684 p_plugin->playlist_clear(&ex);
685 RETURN_ON_EXCEPTION(this,ex);
686 VOID_TO_NPVARIANT(result);
687 return INVOKERESULT_NO_ERROR;
689 return INVOKERESULT_NO_SUCH_METHOD;
690 case ID_playlistitems_remove:
691 if( (argCount == 1) && isNumberValue(args[0]) )
693 p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
694 RETURN_ON_EXCEPTION(this,ex);
695 VOID_TO_NPVARIANT(result);
696 return INVOKERESULT_NO_ERROR;
698 return INVOKERESULT_NO_SUCH_METHOD;
703 return INVOKERESULT_GENERIC_ERROR;
707 ** implementation of libvlc playlist object
710 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
712 // Why the isValid()?
713 if( isValid() && playlistItemsObj )
714 NPN_ReleaseObject(playlistItemsObj);
717 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
719 "itemCount", /* deprecated */
723 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
725 enum LibvlcPlaylistNPObjectPropertyIds
727 ID_playlist_itemcount,
728 ID_playlist_isplaying,
732 RuntimeNPObject::InvokeResult
733 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
735 /* is plugin still running */
736 if( isPluginRunning() )
738 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
739 libvlc_exception_t ex;
740 libvlc_exception_init(&ex);
744 case ID_playlist_itemcount: /* deprecated */
746 int val = p_plugin->playlist_count(&ex);
747 RETURN_ON_EXCEPTION(this,ex);
748 INT32_TO_NPVARIANT(val, result);
749 return INVOKERESULT_NO_ERROR;
751 case ID_playlist_isplaying:
753 int val = p_plugin->playlist_isplaying(&ex);
754 RETURN_ON_EXCEPTION(this,ex);
755 BOOLEAN_TO_NPVARIANT(val, result);
756 return INVOKERESULT_NO_ERROR;
758 case ID_playlist_items:
760 // create child object in lazyman fashion to avoid
761 // ownership problem with firefox
762 if( ! playlistItemsObj )
764 NPN_CreateObject(_instance, RuntimeNPClass<
765 LibvlcPlaylistItemsNPObject>::getClass());
766 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
767 return INVOKERESULT_NO_ERROR;
773 return INVOKERESULT_GENERIC_ERROR;
776 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
785 "clear", /* deprecated */
786 "removeItem", /* deprecated */
788 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
790 enum LibvlcPlaylistNPObjectMethodIds
794 ID_playlist_playItem,
795 ID_playlist_togglepause,
800 ID_playlist_removeitem
803 RuntimeNPObject::InvokeResult
804 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
805 uint32_t argCount, NPVariant &result)
807 /* is plugin still running */
808 if( isPluginRunning() )
810 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
811 libvlc_exception_t ex;
812 libvlc_exception_init(&ex);
816 // XXX FIXME this needs squashing into something much smaller
817 case ID_playlist_add:
819 if( (argCount < 1) || (argCount > 3) )
820 return INVOKERESULT_NO_SUCH_METHOD;
821 if( !NPVARIANT_IS_STRING(args[0]) )
822 return INVOKERESULT_NO_SUCH_METHOD;
825 if( NPVARIANT_IS_NULL(args[0]) )
826 return INVOKERESULT_NO_SUCH_METHOD;
828 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
830 return INVOKERESULT_OUT_OF_MEMORY;
832 char *url = p_plugin->getAbsoluteURL(s);
836 // problem with combining url, use argument
841 // grab name if available
844 if( NPVARIANT_IS_NULL(args[1]) )
848 else if( NPVARIANT_IS_STRING(args[1]) )
850 name = stringValue(NPVARIANT_TO_STRING(args[1]));
855 return INVOKERESULT_INVALID_VALUE;
860 char** ppsz_options = NULL;
862 // grab options if available
865 if( NPVARIANT_IS_NULL(args[2]) )
869 else if( NPVARIANT_IS_STRING(args[2]) )
871 parseOptions(NPVARIANT_TO_STRING(args[2]),
872 &i_options, &ppsz_options);
875 else if( NPVARIANT_IS_OBJECT(args[2]) )
877 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
878 &i_options, &ppsz_options);
884 return INVOKERESULT_INVALID_VALUE;
888 int item = p_plugin->playlist_add_extended_untrusted(url, name,
889 i_options, const_cast<const char **>(ppsz_options), &ex);
892 for( int i=0; i< i_options; ++i )
894 free(ppsz_options[i]);
898 RETURN_ON_EXCEPTION(this,ex);
899 INT32_TO_NPVARIANT(item, result);
900 return INVOKERESULT_NO_ERROR;
902 case ID_playlist_play:
905 p_plugin->playlist_play(&ex);
906 RETURN_ON_EXCEPTION(this,ex);
907 VOID_TO_NPVARIANT(result);
908 return INVOKERESULT_NO_ERROR;
910 return INVOKERESULT_NO_SUCH_METHOD;
911 case ID_playlist_playItem:
912 if( (argCount == 1) && isNumberValue(args[0]) )
914 p_plugin->playlist_play_item(numberValue(args[0]),&ex);
915 RETURN_ON_EXCEPTION(this,ex);
916 VOID_TO_NPVARIANT(result);
917 return INVOKERESULT_NO_ERROR;
919 return INVOKERESULT_NO_SUCH_METHOD;
920 case ID_playlist_togglepause:
923 p_plugin->playlist_pause(&ex);
924 RETURN_ON_EXCEPTION(this,ex);
925 VOID_TO_NPVARIANT(result);
926 return INVOKERESULT_NO_ERROR;
928 return INVOKERESULT_NO_SUCH_METHOD;
929 case ID_playlist_stop:
932 p_plugin->playlist_stop(&ex);
933 RETURN_ON_EXCEPTION(this,ex);
934 VOID_TO_NPVARIANT(result);
935 return INVOKERESULT_NO_ERROR;
937 return INVOKERESULT_NO_SUCH_METHOD;
938 case ID_playlist_next:
941 p_plugin->playlist_next(&ex);
942 RETURN_ON_EXCEPTION(this,ex);
943 VOID_TO_NPVARIANT(result);
944 return INVOKERESULT_NO_ERROR;
946 return INVOKERESULT_NO_SUCH_METHOD;
947 case ID_playlist_prev:
950 p_plugin->playlist_prev(&ex);
951 RETURN_ON_EXCEPTION(this,ex);
952 VOID_TO_NPVARIANT(result);
953 return INVOKERESULT_NO_ERROR;
955 return INVOKERESULT_NO_SUCH_METHOD;
956 case ID_playlist_clear: /* deprecated */
959 p_plugin->playlist_clear(&ex);
960 RETURN_ON_EXCEPTION(this,ex);
961 VOID_TO_NPVARIANT(result);
962 return INVOKERESULT_NO_ERROR;
964 return INVOKERESULT_NO_SUCH_METHOD;
965 case ID_playlist_removeitem: /* deprecated */
966 if( (argCount == 1) && isNumberValue(args[0]) )
968 p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
969 RETURN_ON_EXCEPTION(this,ex);
970 VOID_TO_NPVARIANT(result);
971 return INVOKERESULT_NO_ERROR;
973 return INVOKERESULT_NO_SUCH_METHOD;
978 return INVOKERESULT_GENERIC_ERROR;
981 // XXX FIXME The new playlist_add creates a media instance and feeds it
982 // XXX FIXME these options one at a time, so this hunk of code does lots
983 // XXX FIXME of unnecessairy work. Break out something that can do one
984 // XXX FIXME option at a time and doesn't need to realloc().
985 // XXX FIXME Same for the other version of parseOptions.
987 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
988 int *i_options, char*** ppsz_options)
992 char *s = stringValue(nps);
997 char **options = (char **)malloc(capacity*sizeof(char *));
1002 char *end = val + nps.utf8length;
1005 // skip leading blanks
1007 && ((*val == ' ' ) || (*val == '\t')) )
1011 // skip till we get a blank character
1017 if( ('\'' == c) || ('"' == c) )
1019 // skip till end of string
1020 while( (val < end) && (*(val++) != c ) );
1026 if( nOptions == capacity )
1029 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1032 /* failed to allocate more memory */
1034 /* return what we got so far */
1035 *i_options = nOptions;
1036 *ppsz_options = options;
1039 options = moreOptions;
1042 options[nOptions++] = strdup(start);
1045 // must be end of string
1048 *i_options = nOptions;
1049 *ppsz_options = options;
1056 // XXX FIXME See comment at the other parseOptions variant.
1057 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1058 char*** ppsz_options)
1060 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1064 /* we are expecting to have a Javascript Array object */
1065 NPIdentifier propId = NPN_GetStringIdentifier("length");
1066 if( NPN_GetProperty(_instance, obj, propId, &value) )
1068 int count = numberValue(value);
1069 NPN_ReleaseVariantValue(&value);
1074 char **options = (char **)malloc(capacity*sizeof(char *));
1079 while( nOptions < count )
1081 propId = NPN_GetIntIdentifier(nOptions);
1082 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1083 /* return what we got so far */
1086 if( ! NPVARIANT_IS_STRING(value) )
1088 /* return what we got so far */
1089 NPN_ReleaseVariantValue(&value);
1093 if( nOptions == capacity )
1096 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1099 /* failed to allocate more memory */
1100 NPN_ReleaseVariantValue(&value);
1101 /* return what we got so far */
1102 *i_options = nOptions;
1103 *ppsz_options = options;
1106 options = moreOptions;
1109 options[nOptions++] = stringValue(value);
1110 NPN_ReleaseVariantValue(&value);
1112 *i_options = nOptions;
1113 *ppsz_options = options;
1120 ** implementation of libvlc subtitle object
1123 const NPUTF8 * const LibvlcSubtitleNPObject::propertyNames[] =
1129 enum LibvlcSubtitleNPObjectPropertyIds
1134 COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
1136 RuntimeNPObject::InvokeResult
1137 LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
1139 /* is plugin still running */
1140 if( isPluginRunning() )
1142 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1143 libvlc_exception_t ex;
1144 libvlc_exception_init(&ex);
1146 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1147 RETURN_ON_EXCEPTION(this,ex);
1151 case ID_subtitle_track:
1153 /* get the current subtitle ID */
1154 int i_spu = libvlc_video_get_spu(p_md, &ex);
1155 RETURN_ON_EXCEPTION(this,ex);
1157 INT32_TO_NPVARIANT(i_spu, result);
1158 return INVOKERESULT_NO_ERROR;
1160 case ID_subtitle_count:
1162 /* get the number of subtitles available */
1163 int i_spu = libvlc_video_get_spu_count(p_md, &ex);
1164 RETURN_ON_EXCEPTION(this,ex);
1166 INT32_TO_NPVARIANT(i_spu, result);
1167 return INVOKERESULT_NO_ERROR;
1171 return INVOKERESULT_GENERIC_ERROR;
1174 RuntimeNPObject::InvokeResult
1175 LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
1177 /* is plugin still running */
1178 if( isPluginRunning() )
1180 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1181 libvlc_exception_t ex;
1182 libvlc_exception_init(&ex);
1184 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1185 RETURN_ON_EXCEPTION(this,ex);
1189 case ID_subtitle_track:
1191 if( isNumberValue(value) )
1193 /* set the new subtitle track to show */
1194 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1195 RETURN_ON_EXCEPTION(this,ex);
1197 return INVOKERESULT_NO_ERROR;
1199 return INVOKERESULT_INVALID_VALUE;
1203 return INVOKERESULT_GENERIC_ERROR;
1206 const NPUTF8 * const LibvlcSubtitleNPObject::methodNames[] =
1210 COUNTNAMES(LibvlcSubtitleNPObject,methodCount,methodNames);
1212 enum LibvlcSubtitleNPObjectMethodIds
1214 ID_subtitle_description
1217 RuntimeNPObject::InvokeResult
1218 LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
1219 uint32_t argCount, NPVariant &result)
1221 /* is plugin still running */
1222 if( isPluginRunning() )
1224 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1225 libvlc_exception_t ex;
1226 libvlc_exception_init(&ex);
1228 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1229 RETURN_ON_EXCEPTION(this,ex);
1233 case ID_subtitle_description:
1238 int i_spuID, i_limit, i;
1239 libvlc_track_description_t *p_spuDesc;
1241 /* get subtitles description */
1242 p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
1243 RETURN_ON_EXCEPTION(this,ex);
1245 return INVOKERESULT_GENERIC_ERROR;
1247 /* get the number of subtitle available */
1248 i_limit = libvlc_video_get_spu_count(p_md, &ex);
1249 RETURN_ON_EXCEPTION(this,ex);
1251 /* check if a number is given by the user
1252 * and get the subtitle number */
1253 if( isNumberValue(args[0]) )
1254 i_spuID = numberValue(args[0]);
1256 return INVOKERESULT_INVALID_VALUE;
1258 /* if bad number is given return invalid value */
1259 if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
1260 return INVOKERESULT_INVALID_VALUE;
1262 /* get the good spuDesc */
1263 for( i = 0 ; i < i_spuID ; i++ )
1265 p_spuDesc = p_spuDesc->p_next;
1267 psz_name = p_spuDesc->psz_name;
1269 /* return the name of the track chosen */
1270 return invokeResultString(psz_name, result);
1272 return INVOKERESULT_NO_SUCH_METHOD;
1275 return INVOKERESULT_NO_SUCH_METHOD;
1278 return INVOKERESULT_GENERIC_ERROR;
1282 ** implementation of libvlc video object
1285 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1297 enum LibvlcVideoNPObjectPropertyIds
1299 ID_video_fullscreen,
1302 ID_video_aspectratio,
1308 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1310 RuntimeNPObject::InvokeResult
1311 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1313 /* is plugin still running */
1314 if( isPluginRunning() )
1316 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1317 libvlc_exception_t ex;
1318 libvlc_exception_init(&ex);
1320 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1321 RETURN_ON_EXCEPTION(this,ex);
1325 case ID_video_fullscreen:
1327 int val = p_plugin->get_fullscreen(&ex);
1328 RETURN_ON_EXCEPTION(this,ex);
1329 BOOLEAN_TO_NPVARIANT(val, result);
1330 return INVOKERESULT_NO_ERROR;
1332 case ID_video_height:
1334 int val = libvlc_video_get_height(p_md, &ex);
1335 RETURN_ON_EXCEPTION(this,ex);
1336 INT32_TO_NPVARIANT(val, result);
1337 return INVOKERESULT_NO_ERROR;
1339 case ID_video_width:
1341 int val = libvlc_video_get_width(p_md, &ex);
1342 RETURN_ON_EXCEPTION(this,ex);
1343 INT32_TO_NPVARIANT(val, result);
1344 return INVOKERESULT_NO_ERROR;
1346 case ID_video_aspectratio:
1348 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1349 RETURN_ON_EXCEPTION(this,ex);
1351 return INVOKERESULT_GENERIC_ERROR;
1353 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1354 return INVOKERESULT_NO_ERROR;
1356 case ID_video_subtitle:
1358 int i_spu = libvlc_video_get_spu(p_md, &ex);
1359 RETURN_ON_EXCEPTION(this,ex);
1360 INT32_TO_NPVARIANT(i_spu, result);
1361 return INVOKERESULT_NO_ERROR;
1365 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1366 RETURN_ON_EXCEPTION(this,ex);
1368 return INVOKERESULT_GENERIC_ERROR;
1370 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1371 return INVOKERESULT_NO_ERROR;
1373 case ID_video_teletext:
1375 int i_page = libvlc_video_get_teletext(p_md, &ex);
1376 RETURN_ON_EXCEPTION(this,ex);
1377 INT32_TO_NPVARIANT(i_page, result);
1378 return INVOKERESULT_NO_ERROR;
1380 case ID_video_marquee:
1383 marqueeObj = NPN_CreateObject(_instance,
1384 RuntimeNPClass<LibvlcMarqueeNPObject>::getClass());
1385 OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
1386 return INVOKERESULT_NO_ERROR;
1390 return INVOKERESULT_GENERIC_ERROR;
1393 RuntimeNPObject::InvokeResult
1394 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1396 /* is plugin still running */
1397 if( isPluginRunning() )
1399 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1400 libvlc_exception_t ex;
1401 libvlc_exception_init(&ex);
1403 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1404 RETURN_ON_EXCEPTION(this,ex);
1408 case ID_video_fullscreen:
1410 if( ! NPVARIANT_IS_BOOLEAN(value) )
1412 return INVOKERESULT_INVALID_VALUE;
1415 int val = NPVARIANT_TO_BOOLEAN(value);
1416 p_plugin->set_fullscreen(val, &ex);
1417 RETURN_ON_EXCEPTION(this,ex);
1418 return INVOKERESULT_NO_ERROR;
1420 case ID_video_aspectratio:
1422 char *psz_aspect = NULL;
1424 if( ! NPVARIANT_IS_STRING(value) )
1426 return INVOKERESULT_INVALID_VALUE;
1429 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1432 return INVOKERESULT_GENERIC_ERROR;
1435 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1437 RETURN_ON_EXCEPTION(this,ex);
1439 return INVOKERESULT_NO_ERROR;
1441 case ID_video_subtitle:
1443 if( isNumberValue(value) )
1445 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1446 RETURN_ON_EXCEPTION(this,ex);
1448 return INVOKERESULT_NO_ERROR;
1450 return INVOKERESULT_INVALID_VALUE;
1454 char *psz_geometry = NULL;
1456 if( ! NPVARIANT_IS_STRING(value) )
1458 return INVOKERESULT_INVALID_VALUE;
1461 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1464 return INVOKERESULT_GENERIC_ERROR;
1467 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1469 RETURN_ON_EXCEPTION(this,ex);
1471 return INVOKERESULT_NO_ERROR;
1473 case ID_video_teletext:
1475 if( isNumberValue(value) )
1477 libvlc_video_set_teletext(p_md, numberValue(value), &ex);
1478 RETURN_ON_EXCEPTION(this,ex);
1480 return INVOKERESULT_NO_ERROR;
1482 return INVOKERESULT_INVALID_VALUE;
1486 return INVOKERESULT_GENERIC_ERROR;
1489 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1493 "deinterlaceEnable",
1494 "deinterlaceDisable"
1496 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1498 enum LibvlcVideoNPObjectMethodIds
1500 ID_video_togglefullscreen,
1501 ID_video_toggleteletext,
1502 ID_video_deinterlaceenable,
1503 ID_video_deinterlacedisable
1506 RuntimeNPObject::InvokeResult
1507 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1508 uint32_t argCount, NPVariant &result)
1510 /* is plugin still running */
1511 if( isPluginRunning() )
1513 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1514 libvlc_exception_t ex;
1515 libvlc_exception_init(&ex);
1517 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1518 RETURN_ON_EXCEPTION(this,ex);
1522 case ID_video_togglefullscreen:
1526 p_plugin->toggle_fullscreen(&ex);
1527 RETURN_ON_EXCEPTION(this,ex);
1528 VOID_TO_NPVARIANT(result);
1529 return INVOKERESULT_NO_ERROR;
1531 return INVOKERESULT_NO_SUCH_METHOD;
1533 case ID_video_toggleteletext:
1537 libvlc_toggle_teletext(p_md, &ex);
1538 RETURN_ON_EXCEPTION(this,ex);
1539 VOID_TO_NPVARIANT(result);
1540 return INVOKERESULT_NO_ERROR;
1542 return INVOKERESULT_NO_SUCH_METHOD;
1544 case ID_video_deinterlacedisable:
1546 libvlc_video_set_deinterlace(p_md, 0, "", &ex);
1547 RETURN_ON_EXCEPTION(this,ex);
1548 return INVOKERESULT_NO_ERROR;
1550 case ID_video_deinterlaceenable:
1554 if( NPVARIANT_IS_STRING( args[0] ) )
1556 /* get deinterlace mode from the user */
1557 char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1558 /* enable deinterlace filter if possible */
1559 libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
1561 RETURN_ON_EXCEPTION(this,ex);
1562 return INVOKERESULT_NO_ERROR;
1566 return INVOKERESULT_INVALID_VALUE;
1571 return INVOKERESULT_NO_SUCH_METHOD;
1574 return INVOKERESULT_GENERIC_ERROR;
1578 ** implementation of libvlc marquee object
1581 const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
1585 enum LibvlcMarqueeNPObjectPropertyIds
1588 COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
1590 RuntimeNPObject::InvokeResult
1591 LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
1593 /* is plugin still running */
1594 if( isPluginRunning() )
1596 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1597 libvlc_exception_t ex;
1598 libvlc_exception_init(&ex);
1600 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1601 RETURN_ON_EXCEPTION(this,ex);
1607 return INVOKERESULT_GENERIC_ERROR;
1610 RuntimeNPObject::InvokeResult
1611 LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
1613 /* is plugin still running */
1614 if( isPluginRunning() )
1616 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1617 libvlc_exception_t ex;
1618 libvlc_exception_init(&ex);
1620 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1621 RETURN_ON_EXCEPTION(this,ex);
1627 return INVOKERESULT_GENERIC_ERROR;
1630 const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
1644 COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
1646 enum LibvlcMarqueeNPObjectMethodIds
1652 ID_marquee_position,
1661 RuntimeNPObject::InvokeResult
1662 LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
1663 uint32_t argCount, NPVariant &result)
1665 /* is plugin still running */
1666 if( isPluginRunning() )
1668 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1669 libvlc_exception_t ex;
1670 libvlc_exception_init(&ex);
1672 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1673 RETURN_ON_EXCEPTION(this,ex);
1677 case ID_marquee_enable:
1679 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
1680 RETURN_ON_EXCEPTION(this,ex);
1681 return INVOKERESULT_NO_ERROR;
1683 case ID_marquee_disable:
1685 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
1686 RETURN_ON_EXCEPTION(this,ex);
1687 return INVOKERESULT_NO_ERROR;
1689 case ID_marquee_color:
1693 if( NPVARIANT_IS_INT32( args[0] ) )
1695 int i_color = NPVARIANT_TO_INT32( args[0] );
1696 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, i_color, &ex);
1697 RETURN_ON_EXCEPTION(this,ex);
1698 return INVOKERESULT_NO_ERROR;
1701 return INVOKERESULT_GENERIC_ERROR;
1703 return INVOKERESULT_NO_SUCH_METHOD;
1705 case ID_marquee_opacity:
1709 if( NPVARIANT_IS_INT32( args[0] ) )
1711 int i_opacity = NPVARIANT_TO_INT32( args[0] );
1712 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, i_opacity, &ex);
1713 RETURN_ON_EXCEPTION(this,ex);
1714 return INVOKERESULT_NO_ERROR;
1717 return INVOKERESULT_GENERIC_ERROR;
1719 return INVOKERESULT_NO_SUCH_METHOD;
1721 case ID_marquee_position:
1725 if( NPVARIANT_IS_INT32( args[0] ) )
1727 int i_position = NPVARIANT_TO_INT32( args[0] );
1728 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, i_position, &ex);
1729 RETURN_ON_EXCEPTION(this,ex);
1730 return INVOKERESULT_NO_ERROR;
1733 return INVOKERESULT_GENERIC_ERROR;
1735 return INVOKERESULT_NO_SUCH_METHOD;
1737 case ID_marquee_refresh:
1741 if( NPVARIANT_IS_INT32( args[0] ) )
1743 int i_refresh = NPVARIANT_TO_INT32( args[0] );
1744 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, i_refresh, &ex);
1745 RETURN_ON_EXCEPTION(this,ex);
1746 return INVOKERESULT_NO_ERROR;
1749 return INVOKERESULT_GENERIC_ERROR;
1751 return INVOKERESULT_NO_SUCH_METHOD;
1753 case ID_marquee_size:
1757 if( NPVARIANT_IS_INT32( args[0] ) )
1759 int i_size = NPVARIANT_TO_INT32( args[0] );
1760 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, i_size, &ex);
1761 RETURN_ON_EXCEPTION(this,ex);
1762 return INVOKERESULT_NO_ERROR;
1765 return INVOKERESULT_GENERIC_ERROR;
1767 return INVOKERESULT_NO_SUCH_METHOD;
1769 case ID_marquee_text:
1773 if( NPVARIANT_IS_STRING( args[0] ) )
1775 char *psz_text = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1776 libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
1777 RETURN_ON_EXCEPTION(this,ex);
1779 return INVOKERESULT_NO_ERROR;
1782 return INVOKERESULT_GENERIC_ERROR;
1784 return INVOKERESULT_NO_SUCH_METHOD;
1786 case ID_marquee_timeout:
1790 if( NPVARIANT_IS_INT32( args[0] ) )
1792 int i_timeout = NPVARIANT_TO_INT32( args[0] );
1793 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, i_timeout, &ex);
1794 RETURN_ON_EXCEPTION(this,ex);
1795 return INVOKERESULT_NO_ERROR;
1798 return INVOKERESULT_GENERIC_ERROR;
1800 return INVOKERESULT_NO_SUCH_METHOD;
1806 if( NPVARIANT_IS_INT32( args[0] ) )
1808 int i_x = NPVARIANT_TO_INT32( args[0] );
1809 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, i_x, &ex);
1810 RETURN_ON_EXCEPTION(this,ex);
1811 return INVOKERESULT_NO_ERROR;
1814 return INVOKERESULT_GENERIC_ERROR;
1816 return INVOKERESULT_NO_SUCH_METHOD;
1822 if( NPVARIANT_IS_INT32( args[0] ) )
1824 int i_y = NPVARIANT_TO_INT32( args[0] );
1825 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, i_y, &ex);
1826 RETURN_ON_EXCEPTION(this,ex);
1827 return INVOKERESULT_NO_ERROR;
1830 return INVOKERESULT_GENERIC_ERROR;
1832 return INVOKERESULT_NO_SUCH_METHOD;
1835 return INVOKERESULT_NO_SUCH_METHOD;
1838 return INVOKERESULT_GENERIC_ERROR;