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(), &ex);
222 RETURN_ON_EXCEPTION(this,ex);
223 BOOLEAN_TO_NPVARIANT(muted, result);
224 return INVOKERESULT_NO_ERROR;
226 case ID_audio_volume:
228 int volume = libvlc_audio_get_volume(p_plugin->getVLC());
229 INT32_TO_NPVARIANT(volume, result);
230 return INVOKERESULT_NO_ERROR;
234 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
235 RETURN_ON_EXCEPTION(this,ex);
236 int track = libvlc_audio_get_track(p_md, &ex);
237 RETURN_ON_EXCEPTION(this,ex);
238 INT32_TO_NPVARIANT(track, result);
239 return INVOKERESULT_NO_ERROR;
243 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
244 RETURN_ON_EXCEPTION(this,ex);
245 // get the number of audio track available
246 int i_track = libvlc_audio_get_track_count(p_md, &ex);
247 RETURN_ON_EXCEPTION(this,ex);
249 INT32_TO_NPVARIANT(i_track, result);
250 return INVOKERESULT_NO_ERROR;
252 case ID_audio_channel:
254 int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
255 RETURN_ON_EXCEPTION(this,ex);
256 INT32_TO_NPVARIANT(channel, result);
257 return INVOKERESULT_NO_ERROR;
263 return INVOKERESULT_GENERIC_ERROR;
266 RuntimeNPObject::InvokeResult
267 LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
269 /* is plugin still running */
270 if( isPluginRunning() )
272 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
273 libvlc_exception_t ex;
274 libvlc_exception_init(&ex);
279 if( NPVARIANT_IS_BOOLEAN(value) )
281 libvlc_audio_set_mute(p_plugin->getVLC(),
282 NPVARIANT_TO_BOOLEAN(value));
283 return INVOKERESULT_NO_ERROR;
285 return INVOKERESULT_INVALID_VALUE;
286 case ID_audio_volume:
287 if( isNumberValue(value) )
289 libvlc_audio_set_volume(p_plugin->getVLC(),
290 numberValue(value), &ex);
291 RETURN_ON_EXCEPTION(this,ex);
292 return INVOKERESULT_NO_ERROR;
294 return INVOKERESULT_INVALID_VALUE;
296 if( isNumberValue(value) )
298 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
299 RETURN_ON_EXCEPTION(this,ex);
300 libvlc_audio_set_track(p_md, numberValue(value), &ex);
301 RETURN_ON_EXCEPTION(this,ex);
302 return INVOKERESULT_NO_ERROR;
304 return INVOKERESULT_INVALID_VALUE;
305 case ID_audio_channel:
306 if( isNumberValue(value) )
308 libvlc_audio_set_channel(p_plugin->getVLC(),
309 numberValue(value), &ex);
310 RETURN_ON_EXCEPTION(this,ex);
311 return INVOKERESULT_NO_ERROR;
313 return INVOKERESULT_INVALID_VALUE;
318 return INVOKERESULT_GENERIC_ERROR;
321 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
326 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
328 enum LibvlcAudioNPObjectMethodIds
331 ID_audio_description,
334 RuntimeNPObject::InvokeResult
335 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
336 uint32_t argCount, NPVariant &result)
338 /* is plugin still running */
339 if( isPluginRunning() )
341 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
342 libvlc_exception_t ex;
343 libvlc_exception_init(&ex);
347 case ID_audio_togglemute:
350 libvlc_audio_toggle_mute(p_plugin->getVLC());
351 VOID_TO_NPVARIANT(result);
352 return INVOKERESULT_NO_ERROR;
354 return INVOKERESULT_NO_SUCH_METHOD;
355 case ID_audio_description:
360 int i_trackID, i_limit, i;
361 libvlc_track_description_t *p_trackDesc;
363 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
364 RETURN_ON_EXCEPTION(this,ex);
366 /* get tracks description */
367 p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
368 RETURN_ON_EXCEPTION(this,ex);
370 return INVOKERESULT_GENERIC_ERROR;
372 /* get the number of track available */
373 i_limit = libvlc_audio_get_track_count(p_md, &ex);
374 RETURN_ON_EXCEPTION(this,ex);
376 /* check if a number is given by the user
377 * and get the track number */
378 if( isNumberValue(args[0]) )
379 i_trackID = numberValue(args[0]);
381 return INVOKERESULT_INVALID_VALUE;
383 /* if bad number is given return invalid value */
384 if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) )
385 return INVOKERESULT_INVALID_VALUE;
387 /* get the good trackDesc */
388 for( i = 0 ; i < i_trackID ; i++ )
390 p_trackDesc = p_trackDesc->p_next;
392 psz_name = p_trackDesc->psz_name;
394 /* display the name of the track chosen */
395 return invokeResultString( psz_name, result );
397 return INVOKERESULT_NO_SUCH_METHOD;
403 return INVOKERESULT_GENERIC_ERROR;
407 ** implementation of libvlc input object
410 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
420 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
422 enum LibvlcInputNPObjectPropertyIds
433 RuntimeNPObject::InvokeResult
434 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
436 /* is plugin still running */
437 if( isPluginRunning() )
439 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
440 libvlc_exception_t ex;
441 libvlc_exception_init(&ex);
443 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
444 if( libvlc_exception_raised(&ex) )
446 if( index != ID_input_state )
448 NPN_SetException(this, libvlc_errmsg());
449 libvlc_exception_clear(&ex);
450 return INVOKERESULT_GENERIC_ERROR;
454 /* for input state, return CLOSED rather than an exception */
455 INT32_TO_NPVARIANT(0, result);
456 libvlc_exception_clear(&ex);
457 return INVOKERESULT_NO_ERROR;
463 case ID_input_length:
465 double val = (double)libvlc_media_player_get_length(p_md, &ex);
466 RETURN_ON_EXCEPTION(this,ex);
467 DOUBLE_TO_NPVARIANT(val, result);
468 return INVOKERESULT_NO_ERROR;
470 case ID_input_position:
472 double val = libvlc_media_player_get_position(p_md, &ex);
473 RETURN_ON_EXCEPTION(this,ex);
474 DOUBLE_TO_NPVARIANT(val, result);
475 return INVOKERESULT_NO_ERROR;
479 double val = (double)libvlc_media_player_get_time(p_md, &ex);
480 RETURN_ON_EXCEPTION(this,ex);
481 DOUBLE_TO_NPVARIANT(val, result);
482 return INVOKERESULT_NO_ERROR;
486 int val = libvlc_media_player_get_state(p_md, &ex);
487 RETURN_ON_EXCEPTION(this,ex);
488 INT32_TO_NPVARIANT(val, result);
489 return INVOKERESULT_NO_ERROR;
493 float val = libvlc_media_player_get_rate(p_md, &ex);
494 RETURN_ON_EXCEPTION(this,ex);
495 DOUBLE_TO_NPVARIANT(val, result);
496 return INVOKERESULT_NO_ERROR;
500 double val = libvlc_media_player_get_fps(p_md, &ex);
501 RETURN_ON_EXCEPTION(this,ex);
502 DOUBLE_TO_NPVARIANT(val, result);
503 return INVOKERESULT_NO_ERROR;
505 case ID_input_hasvout:
507 bool val = p_plugin->player_has_vout(&ex);
508 RETURN_ON_EXCEPTION(this,ex);
509 BOOLEAN_TO_NPVARIANT(val, result);
510 return INVOKERESULT_NO_ERROR;
516 return INVOKERESULT_GENERIC_ERROR;
519 RuntimeNPObject::InvokeResult
520 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
522 /* is plugin still running */
523 if( isPluginRunning() )
525 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
526 libvlc_exception_t ex;
527 libvlc_exception_init(&ex);
529 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
530 RETURN_ON_EXCEPTION(this,ex);
534 case ID_input_position:
536 if( ! NPVARIANT_IS_DOUBLE(value) )
538 return INVOKERESULT_INVALID_VALUE;
541 float val = (float)NPVARIANT_TO_DOUBLE(value);
542 libvlc_media_player_set_position(p_md, val, &ex);
543 RETURN_ON_EXCEPTION(this,ex);
544 return INVOKERESULT_NO_ERROR;
549 if( NPVARIANT_IS_INT32(value) )
550 val = (int64_t)NPVARIANT_TO_INT32(value);
551 else if( NPVARIANT_IS_DOUBLE(value) )
552 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
555 return INVOKERESULT_INVALID_VALUE;
558 libvlc_media_player_set_time(p_md, val, &ex);
559 RETURN_ON_EXCEPTION(this,ex);
560 return INVOKERESULT_NO_ERROR;
565 if( NPVARIANT_IS_INT32(value) )
566 val = (float)NPVARIANT_TO_INT32(value);
567 else if( NPVARIANT_IS_DOUBLE(value) )
568 val = (float)NPVARIANT_TO_DOUBLE(value);
571 return INVOKERESULT_INVALID_VALUE;
574 libvlc_media_player_set_rate(p_md, val, &ex);
575 RETURN_ON_EXCEPTION(this,ex);
576 return INVOKERESULT_NO_ERROR;
582 return INVOKERESULT_GENERIC_ERROR;
585 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
590 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
592 enum LibvlcInputNPObjectMethodIds
597 RuntimeNPObject::InvokeResult
598 LibvlcInputNPObject::invoke(int index, const NPVariant *args,
599 uint32_t argCount, NPVariant &result)
601 /* is plugin still running */
602 if( isPluginRunning() )
607 return INVOKERESULT_NO_SUCH_METHOD;
612 return INVOKERESULT_GENERIC_ERROR;
616 ** implementation of libvlc playlist items object
619 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
623 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
625 enum LibvlcPlaylistItemsNPObjectPropertyIds
627 ID_playlistitems_count,
630 RuntimeNPObject::InvokeResult
631 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
633 /* is plugin still running */
634 if( isPluginRunning() )
636 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
637 libvlc_exception_t ex;
638 libvlc_exception_init(&ex);
642 case ID_playlistitems_count:
644 int val = p_plugin->playlist_count(&ex);
645 RETURN_ON_EXCEPTION(this,ex);
646 INT32_TO_NPVARIANT(val, result);
647 return INVOKERESULT_NO_ERROR;
653 return INVOKERESULT_GENERIC_ERROR;
656 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
661 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
663 enum LibvlcPlaylistItemsNPObjectMethodIds
665 ID_playlistitems_clear,
666 ID_playlistitems_remove,
669 RuntimeNPObject::InvokeResult
670 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
671 uint32_t argCount, NPVariant &result)
673 /* is plugin still running */
674 if( isPluginRunning() )
676 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
677 libvlc_exception_t ex;
678 libvlc_exception_init(&ex);
682 case ID_playlistitems_clear:
685 p_plugin->playlist_clear(&ex);
686 RETURN_ON_EXCEPTION(this,ex);
687 VOID_TO_NPVARIANT(result);
688 return INVOKERESULT_NO_ERROR;
690 return INVOKERESULT_NO_SUCH_METHOD;
691 case ID_playlistitems_remove:
692 if( (argCount == 1) && isNumberValue(args[0]) )
694 p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
695 RETURN_ON_EXCEPTION(this,ex);
696 VOID_TO_NPVARIANT(result);
697 return INVOKERESULT_NO_ERROR;
699 return INVOKERESULT_NO_SUCH_METHOD;
704 return INVOKERESULT_GENERIC_ERROR;
708 ** implementation of libvlc playlist object
711 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
713 // Why the isValid()?
714 if( isValid() && playlistItemsObj )
715 NPN_ReleaseObject(playlistItemsObj);
718 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
720 "itemCount", /* deprecated */
724 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
726 enum LibvlcPlaylistNPObjectPropertyIds
728 ID_playlist_itemcount,
729 ID_playlist_isplaying,
733 RuntimeNPObject::InvokeResult
734 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
736 /* is plugin still running */
737 if( isPluginRunning() )
739 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
740 libvlc_exception_t ex;
741 libvlc_exception_init(&ex);
745 case ID_playlist_itemcount: /* deprecated */
747 int val = p_plugin->playlist_count(&ex);
748 RETURN_ON_EXCEPTION(this,ex);
749 INT32_TO_NPVARIANT(val, result);
750 return INVOKERESULT_NO_ERROR;
752 case ID_playlist_isplaying:
754 int val = p_plugin->playlist_isplaying(&ex);
755 RETURN_ON_EXCEPTION(this,ex);
756 BOOLEAN_TO_NPVARIANT(val, result);
757 return INVOKERESULT_NO_ERROR;
759 case ID_playlist_items:
761 // create child object in lazyman fashion to avoid
762 // ownership problem with firefox
763 if( ! playlistItemsObj )
765 NPN_CreateObject(_instance, RuntimeNPClass<
766 LibvlcPlaylistItemsNPObject>::getClass());
767 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
768 return INVOKERESULT_NO_ERROR;
774 return INVOKERESULT_GENERIC_ERROR;
777 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
786 "clear", /* deprecated */
787 "removeItem", /* deprecated */
789 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
791 enum LibvlcPlaylistNPObjectMethodIds
795 ID_playlist_playItem,
796 ID_playlist_togglepause,
801 ID_playlist_removeitem
804 RuntimeNPObject::InvokeResult
805 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
806 uint32_t argCount, NPVariant &result)
808 /* is plugin still running */
809 if( isPluginRunning() )
811 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
812 libvlc_exception_t ex;
813 libvlc_exception_init(&ex);
817 // XXX FIXME this needs squashing into something much smaller
818 case ID_playlist_add:
820 if( (argCount < 1) || (argCount > 3) )
821 return INVOKERESULT_NO_SUCH_METHOD;
822 if( !NPVARIANT_IS_STRING(args[0]) )
823 return INVOKERESULT_NO_SUCH_METHOD;
826 if( NPVARIANT_IS_NULL(args[0]) )
827 return INVOKERESULT_NO_SUCH_METHOD;
829 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
831 return INVOKERESULT_OUT_OF_MEMORY;
833 char *url = p_plugin->getAbsoluteURL(s);
837 // problem with combining url, use argument
842 // grab name if available
845 if( NPVARIANT_IS_NULL(args[1]) )
849 else if( NPVARIANT_IS_STRING(args[1]) )
851 name = stringValue(NPVARIANT_TO_STRING(args[1]));
856 return INVOKERESULT_INVALID_VALUE;
861 char** ppsz_options = NULL;
863 // grab options if available
866 if( NPVARIANT_IS_NULL(args[2]) )
870 else if( NPVARIANT_IS_STRING(args[2]) )
872 parseOptions(NPVARIANT_TO_STRING(args[2]),
873 &i_options, &ppsz_options);
876 else if( NPVARIANT_IS_OBJECT(args[2]) )
878 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
879 &i_options, &ppsz_options);
885 return INVOKERESULT_INVALID_VALUE;
889 int item = p_plugin->playlist_add_extended_untrusted(url, name,
890 i_options, const_cast<const char **>(ppsz_options), &ex);
893 for( int i=0; i< i_options; ++i )
895 free(ppsz_options[i]);
899 RETURN_ON_EXCEPTION(this,ex);
900 INT32_TO_NPVARIANT(item, result);
901 return INVOKERESULT_NO_ERROR;
903 case ID_playlist_play:
906 p_plugin->playlist_play(&ex);
907 RETURN_ON_EXCEPTION(this,ex);
908 VOID_TO_NPVARIANT(result);
909 return INVOKERESULT_NO_ERROR;
911 return INVOKERESULT_NO_SUCH_METHOD;
912 case ID_playlist_playItem:
913 if( (argCount == 1) && isNumberValue(args[0]) )
915 p_plugin->playlist_play_item(numberValue(args[0]),&ex);
916 RETURN_ON_EXCEPTION(this,ex);
917 VOID_TO_NPVARIANT(result);
918 return INVOKERESULT_NO_ERROR;
920 return INVOKERESULT_NO_SUCH_METHOD;
921 case ID_playlist_togglepause:
924 p_plugin->playlist_pause(&ex);
925 RETURN_ON_EXCEPTION(this,ex);
926 VOID_TO_NPVARIANT(result);
927 return INVOKERESULT_NO_ERROR;
929 return INVOKERESULT_NO_SUCH_METHOD;
930 case ID_playlist_stop:
933 p_plugin->playlist_stop(&ex);
934 RETURN_ON_EXCEPTION(this,ex);
935 VOID_TO_NPVARIANT(result);
936 return INVOKERESULT_NO_ERROR;
938 return INVOKERESULT_NO_SUCH_METHOD;
939 case ID_playlist_next:
942 p_plugin->playlist_next(&ex);
943 RETURN_ON_EXCEPTION(this,ex);
944 VOID_TO_NPVARIANT(result);
945 return INVOKERESULT_NO_ERROR;
947 return INVOKERESULT_NO_SUCH_METHOD;
948 case ID_playlist_prev:
951 p_plugin->playlist_prev(&ex);
952 RETURN_ON_EXCEPTION(this,ex);
953 VOID_TO_NPVARIANT(result);
954 return INVOKERESULT_NO_ERROR;
956 return INVOKERESULT_NO_SUCH_METHOD;
957 case ID_playlist_clear: /* deprecated */
960 p_plugin->playlist_clear(&ex);
961 RETURN_ON_EXCEPTION(this,ex);
962 VOID_TO_NPVARIANT(result);
963 return INVOKERESULT_NO_ERROR;
965 return INVOKERESULT_NO_SUCH_METHOD;
966 case ID_playlist_removeitem: /* deprecated */
967 if( (argCount == 1) && isNumberValue(args[0]) )
969 p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
970 RETURN_ON_EXCEPTION(this,ex);
971 VOID_TO_NPVARIANT(result);
972 return INVOKERESULT_NO_ERROR;
974 return INVOKERESULT_NO_SUCH_METHOD;
979 return INVOKERESULT_GENERIC_ERROR;
982 // XXX FIXME The new playlist_add creates a media instance and feeds it
983 // XXX FIXME these options one at a time, so this hunk of code does lots
984 // XXX FIXME of unnecessairy work. Break out something that can do one
985 // XXX FIXME option at a time and doesn't need to realloc().
986 // XXX FIXME Same for the other version of parseOptions.
988 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
989 int *i_options, char*** ppsz_options)
993 char *s = stringValue(nps);
998 char **options = (char **)malloc(capacity*sizeof(char *));
1003 char *end = val + nps.utf8length;
1006 // skip leading blanks
1008 && ((*val == ' ' ) || (*val == '\t')) )
1012 // skip till we get a blank character
1018 if( ('\'' == c) || ('"' == c) )
1020 // skip till end of string
1021 while( (val < end) && (*(val++) != c ) );
1027 if( nOptions == capacity )
1030 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1033 /* failed to allocate more memory */
1035 /* return what we got so far */
1036 *i_options = nOptions;
1037 *ppsz_options = options;
1040 options = moreOptions;
1043 options[nOptions++] = strdup(start);
1046 // must be end of string
1049 *i_options = nOptions;
1050 *ppsz_options = options;
1057 // XXX FIXME See comment at the other parseOptions variant.
1058 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1059 char*** ppsz_options)
1061 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1065 /* we are expecting to have a Javascript Array object */
1066 NPIdentifier propId = NPN_GetStringIdentifier("length");
1067 if( NPN_GetProperty(_instance, obj, propId, &value) )
1069 int count = numberValue(value);
1070 NPN_ReleaseVariantValue(&value);
1075 char **options = (char **)malloc(capacity*sizeof(char *));
1080 while( nOptions < count )
1082 propId = NPN_GetIntIdentifier(nOptions);
1083 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1084 /* return what we got so far */
1087 if( ! NPVARIANT_IS_STRING(value) )
1089 /* return what we got so far */
1090 NPN_ReleaseVariantValue(&value);
1094 if( nOptions == capacity )
1097 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1100 /* failed to allocate more memory */
1101 NPN_ReleaseVariantValue(&value);
1102 /* return what we got so far */
1103 *i_options = nOptions;
1104 *ppsz_options = options;
1107 options = moreOptions;
1110 options[nOptions++] = stringValue(value);
1111 NPN_ReleaseVariantValue(&value);
1113 *i_options = nOptions;
1114 *ppsz_options = options;
1121 ** implementation of libvlc subtitle object
1124 const NPUTF8 * const LibvlcSubtitleNPObject::propertyNames[] =
1130 enum LibvlcSubtitleNPObjectPropertyIds
1135 COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
1137 RuntimeNPObject::InvokeResult
1138 LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
1140 /* is plugin still running */
1141 if( isPluginRunning() )
1143 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1144 libvlc_exception_t ex;
1145 libvlc_exception_init(&ex);
1147 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1148 RETURN_ON_EXCEPTION(this,ex);
1152 case ID_subtitle_track:
1154 /* get the current subtitle ID */
1155 int i_spu = libvlc_video_get_spu(p_md, &ex);
1156 RETURN_ON_EXCEPTION(this,ex);
1158 INT32_TO_NPVARIANT(i_spu, result);
1159 return INVOKERESULT_NO_ERROR;
1161 case ID_subtitle_count:
1163 /* get the number of subtitles available */
1164 int i_spu = libvlc_video_get_spu_count(p_md, &ex);
1165 RETURN_ON_EXCEPTION(this,ex);
1167 INT32_TO_NPVARIANT(i_spu, result);
1168 return INVOKERESULT_NO_ERROR;
1172 return INVOKERESULT_GENERIC_ERROR;
1175 RuntimeNPObject::InvokeResult
1176 LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
1178 /* is plugin still running */
1179 if( isPluginRunning() )
1181 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1182 libvlc_exception_t ex;
1183 libvlc_exception_init(&ex);
1185 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1186 RETURN_ON_EXCEPTION(this,ex);
1190 case ID_subtitle_track:
1192 if( isNumberValue(value) )
1194 /* set the new subtitle track to show */
1195 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1196 RETURN_ON_EXCEPTION(this,ex);
1198 return INVOKERESULT_NO_ERROR;
1200 return INVOKERESULT_INVALID_VALUE;
1204 return INVOKERESULT_GENERIC_ERROR;
1207 const NPUTF8 * const LibvlcSubtitleNPObject::methodNames[] =
1211 COUNTNAMES(LibvlcSubtitleNPObject,methodCount,methodNames);
1213 enum LibvlcSubtitleNPObjectMethodIds
1215 ID_subtitle_description
1218 RuntimeNPObject::InvokeResult
1219 LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
1220 uint32_t argCount, NPVariant &result)
1222 /* is plugin still running */
1223 if( isPluginRunning() )
1225 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1226 libvlc_exception_t ex;
1227 libvlc_exception_init(&ex);
1229 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1230 RETURN_ON_EXCEPTION(this,ex);
1234 case ID_subtitle_description:
1239 int i_spuID, i_limit, i;
1240 libvlc_track_description_t *p_spuDesc;
1242 /* get subtitles description */
1243 p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
1244 RETURN_ON_EXCEPTION(this,ex);
1246 return INVOKERESULT_GENERIC_ERROR;
1248 /* get the number of subtitle available */
1249 i_limit = libvlc_video_get_spu_count(p_md, &ex);
1250 RETURN_ON_EXCEPTION(this,ex);
1252 /* check if a number is given by the user
1253 * and get the subtitle number */
1254 if( isNumberValue(args[0]) )
1255 i_spuID = numberValue(args[0]);
1257 return INVOKERESULT_INVALID_VALUE;
1259 /* if bad number is given return invalid value */
1260 if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
1261 return INVOKERESULT_INVALID_VALUE;
1263 /* get the good spuDesc */
1264 for( i = 0 ; i < i_spuID ; i++ )
1266 p_spuDesc = p_spuDesc->p_next;
1268 psz_name = p_spuDesc->psz_name;
1270 /* return the name of the track chosen */
1271 return invokeResultString(psz_name, result);
1273 return INVOKERESULT_NO_SUCH_METHOD;
1276 return INVOKERESULT_NO_SUCH_METHOD;
1279 return INVOKERESULT_GENERIC_ERROR;
1283 ** implementation of libvlc video object
1286 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1298 enum LibvlcVideoNPObjectPropertyIds
1300 ID_video_fullscreen,
1303 ID_video_aspectratio,
1309 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1311 RuntimeNPObject::InvokeResult
1312 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1314 /* is plugin still running */
1315 if( isPluginRunning() )
1317 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1318 libvlc_exception_t ex;
1319 libvlc_exception_init(&ex);
1321 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1322 RETURN_ON_EXCEPTION(this,ex);
1326 case ID_video_fullscreen:
1328 int val = p_plugin->get_fullscreen(&ex);
1329 RETURN_ON_EXCEPTION(this,ex);
1330 BOOLEAN_TO_NPVARIANT(val, result);
1331 return INVOKERESULT_NO_ERROR;
1333 case ID_video_height:
1335 int val = libvlc_video_get_height(p_md, &ex);
1336 RETURN_ON_EXCEPTION(this,ex);
1337 INT32_TO_NPVARIANT(val, result);
1338 return INVOKERESULT_NO_ERROR;
1340 case ID_video_width:
1342 int val = libvlc_video_get_width(p_md, &ex);
1343 RETURN_ON_EXCEPTION(this,ex);
1344 INT32_TO_NPVARIANT(val, result);
1345 return INVOKERESULT_NO_ERROR;
1347 case ID_video_aspectratio:
1349 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1350 RETURN_ON_EXCEPTION(this,ex);
1352 return INVOKERESULT_GENERIC_ERROR;
1354 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1355 return INVOKERESULT_NO_ERROR;
1357 case ID_video_subtitle:
1359 int i_spu = libvlc_video_get_spu(p_md, &ex);
1360 RETURN_ON_EXCEPTION(this,ex);
1361 INT32_TO_NPVARIANT(i_spu, result);
1362 return INVOKERESULT_NO_ERROR;
1366 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1367 RETURN_ON_EXCEPTION(this,ex);
1369 return INVOKERESULT_GENERIC_ERROR;
1371 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1372 return INVOKERESULT_NO_ERROR;
1374 case ID_video_teletext:
1376 int i_page = libvlc_video_get_teletext(p_md, &ex);
1377 RETURN_ON_EXCEPTION(this,ex);
1378 INT32_TO_NPVARIANT(i_page, result);
1379 return INVOKERESULT_NO_ERROR;
1381 case ID_video_marquee:
1384 marqueeObj = NPN_CreateObject(_instance,
1385 RuntimeNPClass<LibvlcMarqueeNPObject>::getClass());
1386 OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
1387 return INVOKERESULT_NO_ERROR;
1391 return INVOKERESULT_GENERIC_ERROR;
1394 RuntimeNPObject::InvokeResult
1395 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1397 /* is plugin still running */
1398 if( isPluginRunning() )
1400 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1401 libvlc_exception_t ex;
1402 libvlc_exception_init(&ex);
1404 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1405 RETURN_ON_EXCEPTION(this,ex);
1409 case ID_video_fullscreen:
1411 if( ! NPVARIANT_IS_BOOLEAN(value) )
1413 return INVOKERESULT_INVALID_VALUE;
1416 int val = NPVARIANT_TO_BOOLEAN(value);
1417 p_plugin->set_fullscreen(val, &ex);
1418 RETURN_ON_EXCEPTION(this,ex);
1419 return INVOKERESULT_NO_ERROR;
1421 case ID_video_aspectratio:
1423 char *psz_aspect = NULL;
1425 if( ! NPVARIANT_IS_STRING(value) )
1427 return INVOKERESULT_INVALID_VALUE;
1430 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1433 return INVOKERESULT_GENERIC_ERROR;
1436 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1438 RETURN_ON_EXCEPTION(this,ex);
1440 return INVOKERESULT_NO_ERROR;
1442 case ID_video_subtitle:
1444 if( isNumberValue(value) )
1446 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1447 RETURN_ON_EXCEPTION(this,ex);
1449 return INVOKERESULT_NO_ERROR;
1451 return INVOKERESULT_INVALID_VALUE;
1455 char *psz_geometry = NULL;
1457 if( ! NPVARIANT_IS_STRING(value) )
1459 return INVOKERESULT_INVALID_VALUE;
1462 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1465 return INVOKERESULT_GENERIC_ERROR;
1468 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1470 RETURN_ON_EXCEPTION(this,ex);
1472 return INVOKERESULT_NO_ERROR;
1474 case ID_video_teletext:
1476 if( isNumberValue(value) )
1478 libvlc_video_set_teletext(p_md, numberValue(value), &ex);
1479 RETURN_ON_EXCEPTION(this,ex);
1481 return INVOKERESULT_NO_ERROR;
1483 return INVOKERESULT_INVALID_VALUE;
1487 return INVOKERESULT_GENERIC_ERROR;
1490 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1494 "deinterlaceEnable",
1495 "deinterlaceDisable"
1497 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1499 enum LibvlcVideoNPObjectMethodIds
1501 ID_video_togglefullscreen,
1502 ID_video_toggleteletext,
1503 ID_video_deinterlaceenable,
1504 ID_video_deinterlacedisable
1507 RuntimeNPObject::InvokeResult
1508 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1509 uint32_t argCount, NPVariant &result)
1511 /* is plugin still running */
1512 if( isPluginRunning() )
1514 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1515 libvlc_exception_t ex;
1516 libvlc_exception_init(&ex);
1518 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1519 RETURN_ON_EXCEPTION(this,ex);
1523 case ID_video_togglefullscreen:
1527 p_plugin->toggle_fullscreen(&ex);
1528 RETURN_ON_EXCEPTION(this,ex);
1529 VOID_TO_NPVARIANT(result);
1530 return INVOKERESULT_NO_ERROR;
1532 return INVOKERESULT_NO_SUCH_METHOD;
1534 case ID_video_toggleteletext:
1538 libvlc_toggle_teletext(p_md, &ex);
1539 RETURN_ON_EXCEPTION(this,ex);
1540 VOID_TO_NPVARIANT(result);
1541 return INVOKERESULT_NO_ERROR;
1543 return INVOKERESULT_NO_SUCH_METHOD;
1545 case ID_video_deinterlacedisable:
1547 libvlc_video_set_deinterlace(p_md, 0, "", &ex);
1548 RETURN_ON_EXCEPTION(this,ex);
1549 return INVOKERESULT_NO_ERROR;
1551 case ID_video_deinterlaceenable:
1555 if( NPVARIANT_IS_STRING( args[0] ) )
1557 /* get deinterlace mode from the user */
1558 char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1559 /* enable deinterlace filter if possible */
1560 libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
1562 RETURN_ON_EXCEPTION(this,ex);
1563 return INVOKERESULT_NO_ERROR;
1567 return INVOKERESULT_INVALID_VALUE;
1572 return INVOKERESULT_NO_SUCH_METHOD;
1575 return INVOKERESULT_GENERIC_ERROR;
1579 ** implementation of libvlc marquee object
1582 const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
1586 enum LibvlcMarqueeNPObjectPropertyIds
1589 COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
1591 RuntimeNPObject::InvokeResult
1592 LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
1594 /* is plugin still running */
1595 if( isPluginRunning() )
1597 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1598 libvlc_exception_t ex;
1599 libvlc_exception_init(&ex);
1601 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1602 RETURN_ON_EXCEPTION(this,ex);
1608 return INVOKERESULT_GENERIC_ERROR;
1611 RuntimeNPObject::InvokeResult
1612 LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
1614 /* is plugin still running */
1615 if( isPluginRunning() )
1617 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1618 libvlc_exception_t ex;
1619 libvlc_exception_init(&ex);
1621 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1622 RETURN_ON_EXCEPTION(this,ex);
1628 return INVOKERESULT_GENERIC_ERROR;
1631 const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
1645 COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
1647 enum LibvlcMarqueeNPObjectMethodIds
1653 ID_marquee_position,
1662 RuntimeNPObject::InvokeResult
1663 LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
1664 uint32_t argCount, NPVariant &result)
1666 /* is plugin still running */
1667 if( isPluginRunning() )
1669 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1670 libvlc_exception_t ex;
1671 libvlc_exception_init(&ex);
1673 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1674 RETURN_ON_EXCEPTION(this,ex);
1678 case ID_marquee_enable:
1680 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
1681 RETURN_ON_EXCEPTION(this,ex);
1682 return INVOKERESULT_NO_ERROR;
1684 case ID_marquee_disable:
1686 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
1687 RETURN_ON_EXCEPTION(this,ex);
1688 return INVOKERESULT_NO_ERROR;
1690 case ID_marquee_color:
1694 if( NPVARIANT_IS_INT32( args[0] ) )
1696 int i_color = NPVARIANT_TO_INT32( args[0] );
1697 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, i_color, &ex);
1698 RETURN_ON_EXCEPTION(this,ex);
1699 return INVOKERESULT_NO_ERROR;
1702 return INVOKERESULT_GENERIC_ERROR;
1704 return INVOKERESULT_NO_SUCH_METHOD;
1706 case ID_marquee_opacity:
1710 if( NPVARIANT_IS_INT32( args[0] ) )
1712 int i_opacity = NPVARIANT_TO_INT32( args[0] );
1713 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, i_opacity, &ex);
1714 RETURN_ON_EXCEPTION(this,ex);
1715 return INVOKERESULT_NO_ERROR;
1718 return INVOKERESULT_GENERIC_ERROR;
1720 return INVOKERESULT_NO_SUCH_METHOD;
1722 case ID_marquee_position:
1726 if( NPVARIANT_IS_INT32( args[0] ) )
1728 int i_position = NPVARIANT_TO_INT32( args[0] );
1729 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, i_position, &ex);
1730 RETURN_ON_EXCEPTION(this,ex);
1731 return INVOKERESULT_NO_ERROR;
1734 return INVOKERESULT_GENERIC_ERROR;
1736 return INVOKERESULT_NO_SUCH_METHOD;
1738 case ID_marquee_refresh:
1742 if( NPVARIANT_IS_INT32( args[0] ) )
1744 int i_refresh = NPVARIANT_TO_INT32( args[0] );
1745 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, i_refresh, &ex);
1746 RETURN_ON_EXCEPTION(this,ex);
1747 return INVOKERESULT_NO_ERROR;
1750 return INVOKERESULT_GENERIC_ERROR;
1752 return INVOKERESULT_NO_SUCH_METHOD;
1754 case ID_marquee_size:
1758 if( NPVARIANT_IS_INT32( args[0] ) )
1760 int i_size = NPVARIANT_TO_INT32( args[0] );
1761 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, i_size, &ex);
1762 RETURN_ON_EXCEPTION(this,ex);
1763 return INVOKERESULT_NO_ERROR;
1766 return INVOKERESULT_GENERIC_ERROR;
1768 return INVOKERESULT_NO_SUCH_METHOD;
1770 case ID_marquee_text:
1774 if( NPVARIANT_IS_STRING( args[0] ) )
1776 char *psz_text = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1777 libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
1778 RETURN_ON_EXCEPTION(this,ex);
1780 return INVOKERESULT_NO_ERROR;
1783 return INVOKERESULT_GENERIC_ERROR;
1785 return INVOKERESULT_NO_SUCH_METHOD;
1787 case ID_marquee_timeout:
1791 if( NPVARIANT_IS_INT32( args[0] ) )
1793 int i_timeout = NPVARIANT_TO_INT32( args[0] );
1794 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, i_timeout, &ex);
1795 RETURN_ON_EXCEPTION(this,ex);
1796 return INVOKERESULT_NO_ERROR;
1799 return INVOKERESULT_GENERIC_ERROR;
1801 return INVOKERESULT_NO_SUCH_METHOD;
1807 if( NPVARIANT_IS_INT32( args[0] ) )
1809 int i_x = NPVARIANT_TO_INT32( args[0] );
1810 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, i_x, &ex);
1811 RETURN_ON_EXCEPTION(this,ex);
1812 return INVOKERESULT_NO_ERROR;
1815 return INVOKERESULT_GENERIC_ERROR;
1817 return INVOKERESULT_NO_SUCH_METHOD;
1823 if( NPVARIANT_IS_INT32( args[0] ) )
1825 int i_y = NPVARIANT_TO_INT32( args[0] );
1826 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, i_y, &ex);
1827 RETURN_ON_EXCEPTION(this,ex);
1828 return INVOKERESULT_NO_ERROR;
1831 return INVOKERESULT_GENERIC_ERROR;
1833 return INVOKERESULT_NO_SUCH_METHOD;
1836 return INVOKERESULT_NO_SUCH_METHOD;
1839 return INVOKERESULT_GENERIC_ERROR;