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_exception_get_message(&ex)); \
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(), &ex);
229 RETURN_ON_EXCEPTION(this,ex);
230 INT32_TO_NPVARIANT(volume, result);
231 return INVOKERESULT_NO_ERROR;
235 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
236 RETURN_ON_EXCEPTION(this,ex);
237 int track = libvlc_audio_get_track(p_md, &ex);
238 RETURN_ON_EXCEPTION(this,ex);
239 INT32_TO_NPVARIANT(track, result);
240 return INVOKERESULT_NO_ERROR;
244 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
245 RETURN_ON_EXCEPTION(this,ex);
246 // get the number of audio track available
247 int i_track = libvlc_audio_get_track_count(p_md, &ex);
248 RETURN_ON_EXCEPTION(this,ex);
250 INT32_TO_NPVARIANT(i_track, result);
251 return INVOKERESULT_NO_ERROR;
253 case ID_audio_channel:
255 int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
256 RETURN_ON_EXCEPTION(this,ex);
257 INT32_TO_NPVARIANT(channel, result);
258 return INVOKERESULT_NO_ERROR;
264 return INVOKERESULT_GENERIC_ERROR;
267 RuntimeNPObject::InvokeResult
268 LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
270 /* is plugin still running */
271 if( isPluginRunning() )
273 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
274 libvlc_exception_t ex;
275 libvlc_exception_init(&ex);
280 if( NPVARIANT_IS_BOOLEAN(value) )
282 libvlc_audio_set_mute(p_plugin->getVLC(),
283 NPVARIANT_TO_BOOLEAN(value), &ex);
284 RETURN_ON_EXCEPTION(this,ex);
285 return INVOKERESULT_NO_ERROR;
287 return INVOKERESULT_INVALID_VALUE;
288 case ID_audio_volume:
289 if( isNumberValue(value) )
291 libvlc_audio_set_volume(p_plugin->getVLC(),
292 numberValue(value), &ex);
293 RETURN_ON_EXCEPTION(this,ex);
294 return INVOKERESULT_NO_ERROR;
296 return INVOKERESULT_INVALID_VALUE;
298 if( isNumberValue(value) )
300 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
301 RETURN_ON_EXCEPTION(this,ex);
302 libvlc_audio_set_track(p_md, numberValue(value), &ex);
303 RETURN_ON_EXCEPTION(this,ex);
304 return INVOKERESULT_NO_ERROR;
306 return INVOKERESULT_INVALID_VALUE;
307 case ID_audio_channel:
308 if( isNumberValue(value) )
310 libvlc_audio_set_channel(p_plugin->getVLC(),
311 numberValue(value), &ex);
312 RETURN_ON_EXCEPTION(this,ex);
313 return INVOKERESULT_NO_ERROR;
315 return INVOKERESULT_INVALID_VALUE;
320 return INVOKERESULT_GENERIC_ERROR;
323 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
328 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
330 enum LibvlcAudioNPObjectMethodIds
333 ID_audio_description,
336 RuntimeNPObject::InvokeResult
337 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
338 uint32_t argCount, NPVariant &result)
340 /* is plugin still running */
341 if( isPluginRunning() )
343 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
344 libvlc_exception_t ex;
345 libvlc_exception_init(&ex);
349 case ID_audio_togglemute:
352 libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
353 RETURN_ON_EXCEPTION(this,ex);
354 VOID_TO_NPVARIANT(result);
355 return INVOKERESULT_NO_ERROR;
357 return INVOKERESULT_NO_SUCH_METHOD;
358 case ID_audio_description:
363 int i_trackID, i_limit, i;
364 libvlc_track_description_t *p_trackDesc;
366 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
367 RETURN_ON_EXCEPTION(this,ex);
369 /* get tracks description */
370 p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
371 RETURN_ON_EXCEPTION(this,ex);
373 return INVOKERESULT_GENERIC_ERROR;
375 /* get the number of track available */
376 i_limit = libvlc_audio_get_track_count(p_md, &ex);
377 RETURN_ON_EXCEPTION(this,ex);
379 /* check if a number is given by the user
380 * and get the track number */
381 if( isNumberValue(args[0]) )
382 i_trackID = numberValue(args[0]);
384 return INVOKERESULT_INVALID_VALUE;
386 /* if bad number is given return invalid value */
387 if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) )
388 return INVOKERESULT_INVALID_VALUE;
390 /* get the good trackDesc */
391 for( i = 0 ; i < i_trackID ; i++ )
393 p_trackDesc = p_trackDesc->p_next;
395 psz_name = p_trackDesc->psz_name;
397 /* display the name of the track chosen */
398 return invokeResultString( psz_name, result );
400 return INVOKERESULT_NO_SUCH_METHOD;
406 return INVOKERESULT_GENERIC_ERROR;
410 ** implementation of libvlc input object
413 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
423 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
425 enum LibvlcInputNPObjectPropertyIds
436 RuntimeNPObject::InvokeResult
437 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
439 /* is plugin still running */
440 if( isPluginRunning() )
442 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
443 libvlc_exception_t ex;
444 libvlc_exception_init(&ex);
446 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
447 if( libvlc_exception_raised(&ex) )
449 if( index != ID_input_state )
451 NPN_SetException(this, libvlc_exception_get_message(&ex));
452 libvlc_exception_clear(&ex);
453 return INVOKERESULT_GENERIC_ERROR;
457 /* for input state, return CLOSED rather than an exception */
458 INT32_TO_NPVARIANT(0, result);
459 libvlc_exception_clear(&ex);
460 return INVOKERESULT_NO_ERROR;
466 case ID_input_length:
468 double val = (double)libvlc_media_player_get_length(p_md, &ex);
469 RETURN_ON_EXCEPTION(this,ex);
470 DOUBLE_TO_NPVARIANT(val, result);
471 return INVOKERESULT_NO_ERROR;
473 case ID_input_position:
475 double val = libvlc_media_player_get_position(p_md, &ex);
476 RETURN_ON_EXCEPTION(this,ex);
477 DOUBLE_TO_NPVARIANT(val, result);
478 return INVOKERESULT_NO_ERROR;
482 double val = (double)libvlc_media_player_get_time(p_md, &ex);
483 RETURN_ON_EXCEPTION(this,ex);
484 DOUBLE_TO_NPVARIANT(val, result);
485 return INVOKERESULT_NO_ERROR;
489 int val = libvlc_media_player_get_state(p_md, &ex);
490 RETURN_ON_EXCEPTION(this,ex);
491 INT32_TO_NPVARIANT(val, result);
492 return INVOKERESULT_NO_ERROR;
496 float val = libvlc_media_player_get_rate(p_md, &ex);
497 RETURN_ON_EXCEPTION(this,ex);
498 DOUBLE_TO_NPVARIANT(val, result);
499 return INVOKERESULT_NO_ERROR;
503 double val = libvlc_media_player_get_fps(p_md, &ex);
504 RETURN_ON_EXCEPTION(this,ex);
505 DOUBLE_TO_NPVARIANT(val, result);
506 return INVOKERESULT_NO_ERROR;
508 case ID_input_hasvout:
510 bool val = p_plugin->player_has_vout(&ex);
511 RETURN_ON_EXCEPTION(this,ex);
512 BOOLEAN_TO_NPVARIANT(val, result);
513 return INVOKERESULT_NO_ERROR;
519 return INVOKERESULT_GENERIC_ERROR;
522 RuntimeNPObject::InvokeResult
523 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
525 /* is plugin still running */
526 if( isPluginRunning() )
528 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
529 libvlc_exception_t ex;
530 libvlc_exception_init(&ex);
532 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
533 RETURN_ON_EXCEPTION(this,ex);
537 case ID_input_position:
539 if( ! NPVARIANT_IS_DOUBLE(value) )
541 return INVOKERESULT_INVALID_VALUE;
544 float val = (float)NPVARIANT_TO_DOUBLE(value);
545 libvlc_media_player_set_position(p_md, val, &ex);
546 RETURN_ON_EXCEPTION(this,ex);
547 return INVOKERESULT_NO_ERROR;
552 if( NPVARIANT_IS_INT32(value) )
553 val = (int64_t)NPVARIANT_TO_INT32(value);
554 else if( NPVARIANT_IS_DOUBLE(value) )
555 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
558 return INVOKERESULT_INVALID_VALUE;
561 libvlc_media_player_set_time(p_md, val, &ex);
562 RETURN_ON_EXCEPTION(this,ex);
563 return INVOKERESULT_NO_ERROR;
568 if( NPVARIANT_IS_INT32(value) )
569 val = (float)NPVARIANT_TO_INT32(value);
570 else if( NPVARIANT_IS_DOUBLE(value) )
571 val = (float)NPVARIANT_TO_DOUBLE(value);
574 return INVOKERESULT_INVALID_VALUE;
577 libvlc_media_player_set_rate(p_md, val, &ex);
578 RETURN_ON_EXCEPTION(this,ex);
579 return INVOKERESULT_NO_ERROR;
585 return INVOKERESULT_GENERIC_ERROR;
588 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
593 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
596 ** implementation of libvlc playlist items object
599 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
603 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
605 enum LibvlcPlaylistItemsNPObjectPropertyIds
607 ID_playlistitems_count,
610 RuntimeNPObject::InvokeResult
611 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
613 /* is plugin still running */
614 if( isPluginRunning() )
616 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
617 libvlc_exception_t ex;
618 libvlc_exception_init(&ex);
622 case ID_playlistitems_count:
624 int val = p_plugin->playlist_count(&ex);
625 RETURN_ON_EXCEPTION(this,ex);
626 INT32_TO_NPVARIANT(val, result);
627 return INVOKERESULT_NO_ERROR;
633 return INVOKERESULT_GENERIC_ERROR;
636 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
641 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
643 enum LibvlcPlaylistItemsNPObjectMethodIds
645 ID_playlistitems_clear,
646 ID_playlistitems_remove,
649 RuntimeNPObject::InvokeResult
650 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
651 uint32_t argCount, NPVariant &result)
653 /* is plugin still running */
654 if( isPluginRunning() )
656 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
657 libvlc_exception_t ex;
658 libvlc_exception_init(&ex);
662 case ID_playlistitems_clear:
665 p_plugin->playlist_clear(&ex);
666 RETURN_ON_EXCEPTION(this,ex);
667 VOID_TO_NPVARIANT(result);
668 return INVOKERESULT_NO_ERROR;
670 return INVOKERESULT_NO_SUCH_METHOD;
671 case ID_playlistitems_remove:
672 if( (argCount == 1) && isNumberValue(args[0]) )
674 p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
675 RETURN_ON_EXCEPTION(this,ex);
676 VOID_TO_NPVARIANT(result);
677 return INVOKERESULT_NO_ERROR;
679 return INVOKERESULT_NO_SUCH_METHOD;
684 return INVOKERESULT_GENERIC_ERROR;
688 ** implementation of libvlc playlist object
691 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
693 // Why the isValid()?
694 if( isValid() && playlistItemsObj )
695 NPN_ReleaseObject(playlistItemsObj);
698 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
700 "itemCount", /* deprecated */
704 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
706 enum LibvlcPlaylistNPObjectPropertyIds
708 ID_playlist_itemcount,
709 ID_playlist_isplaying,
713 RuntimeNPObject::InvokeResult
714 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
716 /* is plugin still running */
717 if( isPluginRunning() )
719 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
720 libvlc_exception_t ex;
721 libvlc_exception_init(&ex);
725 case ID_playlist_itemcount: /* deprecated */
727 int val = p_plugin->playlist_count(&ex);
728 RETURN_ON_EXCEPTION(this,ex);
729 INT32_TO_NPVARIANT(val, result);
730 return INVOKERESULT_NO_ERROR;
732 case ID_playlist_isplaying:
734 int val = p_plugin->playlist_isplaying(&ex);
735 RETURN_ON_EXCEPTION(this,ex);
736 BOOLEAN_TO_NPVARIANT(val, result);
737 return INVOKERESULT_NO_ERROR;
739 case ID_playlist_items:
741 // create child object in lazyman fashion to avoid
742 // ownership problem with firefox
743 if( ! playlistItemsObj )
745 NPN_CreateObject(_instance, RuntimeNPClass<
746 LibvlcPlaylistItemsNPObject>::getClass());
747 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
748 return INVOKERESULT_NO_ERROR;
754 return INVOKERESULT_GENERIC_ERROR;
757 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
766 "clear", /* deprecated */
767 "removeItem", /* deprecated */
769 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
771 enum LibvlcPlaylistNPObjectMethodIds
775 ID_playlist_playItem,
776 ID_playlist_togglepause,
781 ID_playlist_removeitem
784 RuntimeNPObject::InvokeResult
785 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
786 uint32_t argCount, NPVariant &result)
788 /* is plugin still running */
789 if( isPluginRunning() )
791 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
792 libvlc_exception_t ex;
793 libvlc_exception_init(&ex);
797 // XXX FIXME this needs squashing into something much smaller
798 case ID_playlist_add:
800 if( (argCount < 1) || (argCount > 3) )
801 return INVOKERESULT_NO_SUCH_METHOD;
802 if( !NPVARIANT_IS_STRING(args[0]) )
803 return INVOKERESULT_NO_SUCH_METHOD;
806 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
808 return INVOKERESULT_OUT_OF_MEMORY;
810 char *url = p_plugin->getAbsoluteURL(s);
814 // problem with combining url, use argument
819 // grab name if available
822 if( NPVARIANT_IS_NULL(args[1]) )
826 else if( NPVARIANT_IS_STRING(args[1]) )
828 name = stringValue(NPVARIANT_TO_STRING(args[1]));
833 return INVOKERESULT_INVALID_VALUE;
838 char** ppsz_options = NULL;
840 // grab options if available
843 if( NPVARIANT_IS_NULL(args[2]) )
847 else if( NPVARIANT_IS_STRING(args[2]) )
849 parseOptions(NPVARIANT_TO_STRING(args[2]),
850 &i_options, &ppsz_options);
853 else if( NPVARIANT_IS_OBJECT(args[2]) )
855 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
856 &i_options, &ppsz_options);
862 return INVOKERESULT_INVALID_VALUE;
866 int item = p_plugin->playlist_add_extended_untrusted(url, name,
867 i_options, const_cast<const char **>(ppsz_options), &ex);
870 for( int i=0; i< i_options; ++i )
872 free(ppsz_options[i]);
876 RETURN_ON_EXCEPTION(this,ex);
877 INT32_TO_NPVARIANT(item, result);
878 return INVOKERESULT_NO_ERROR;
880 case ID_playlist_play:
883 p_plugin->playlist_play(&ex);
884 RETURN_ON_EXCEPTION(this,ex);
885 VOID_TO_NPVARIANT(result);
886 return INVOKERESULT_NO_ERROR;
888 return INVOKERESULT_NO_SUCH_METHOD;
889 case ID_playlist_playItem:
890 if( (argCount == 1) && isNumberValue(args[0]) )
892 p_plugin->playlist_play_item(numberValue(args[0]),&ex);
893 RETURN_ON_EXCEPTION(this,ex);
894 VOID_TO_NPVARIANT(result);
895 return INVOKERESULT_NO_ERROR;
897 return INVOKERESULT_NO_SUCH_METHOD;
898 case ID_playlist_togglepause:
901 p_plugin->playlist_pause(&ex);
902 RETURN_ON_EXCEPTION(this,ex);
903 VOID_TO_NPVARIANT(result);
904 return INVOKERESULT_NO_ERROR;
906 return INVOKERESULT_NO_SUCH_METHOD;
907 case ID_playlist_stop:
910 p_plugin->playlist_stop(&ex);
911 RETURN_ON_EXCEPTION(this,ex);
912 VOID_TO_NPVARIANT(result);
913 return INVOKERESULT_NO_ERROR;
915 return INVOKERESULT_NO_SUCH_METHOD;
916 case ID_playlist_next:
919 p_plugin->playlist_next(&ex);
920 RETURN_ON_EXCEPTION(this,ex);
921 VOID_TO_NPVARIANT(result);
922 return INVOKERESULT_NO_ERROR;
924 return INVOKERESULT_NO_SUCH_METHOD;
925 case ID_playlist_prev:
928 p_plugin->playlist_prev(&ex);
929 RETURN_ON_EXCEPTION(this,ex);
930 VOID_TO_NPVARIANT(result);
931 return INVOKERESULT_NO_ERROR;
933 return INVOKERESULT_NO_SUCH_METHOD;
934 case ID_playlist_clear: /* deprecated */
937 p_plugin->playlist_clear(&ex);
938 RETURN_ON_EXCEPTION(this,ex);
939 VOID_TO_NPVARIANT(result);
940 return INVOKERESULT_NO_ERROR;
942 return INVOKERESULT_NO_SUCH_METHOD;
943 case ID_playlist_removeitem: /* deprecated */
944 if( (argCount == 1) && isNumberValue(args[0]) )
946 p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
947 RETURN_ON_EXCEPTION(this,ex);
948 VOID_TO_NPVARIANT(result);
949 return INVOKERESULT_NO_ERROR;
951 return INVOKERESULT_NO_SUCH_METHOD;
956 return INVOKERESULT_GENERIC_ERROR;
959 // XXX FIXME The new playlist_add creates a media instance and feeds it
960 // XXX FIXME these options one at a time, so this hunk of code does lots
961 // XXX FIXME of unnecessairy work. Break out something that can do one
962 // XXX FIXME option at a time and doesn't need to realloc().
963 // XXX FIXME Same for the other version of parseOptions.
965 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
966 int *i_options, char*** ppsz_options)
970 char *s = stringValue(nps);
975 char **options = (char **)malloc(capacity*sizeof(char *));
980 char *end = val + nps.utf8length;
983 // skip leading blanks
985 && ((*val == ' ' ) || (*val == '\t')) )
989 // skip till we get a blank character
995 if( ('\'' == c) || ('"' == c) )
997 // skip till end of string
998 while( (val < end) && (*(val++) != c ) );
1004 if( nOptions == capacity )
1007 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1010 /* failed to allocate more memory */
1012 /* return what we got so far */
1013 *i_options = nOptions;
1014 *ppsz_options = options;
1017 options = moreOptions;
1020 options[nOptions++] = strdup(start);
1023 // must be end of string
1026 *i_options = nOptions;
1027 *ppsz_options = options;
1034 // XXX FIXME See comment at the other parseOptions variant.
1035 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1036 char*** ppsz_options)
1038 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1042 /* we are expecting to have a Javascript Array object */
1043 NPIdentifier propId = NPN_GetStringIdentifier("length");
1044 if( NPN_GetProperty(_instance, obj, propId, &value) )
1046 int count = numberValue(value);
1047 NPN_ReleaseVariantValue(&value);
1052 char **options = (char **)malloc(capacity*sizeof(char *));
1057 while( nOptions < count )
1059 propId = NPN_GetIntIdentifier(nOptions);
1060 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1061 /* return what we got so far */
1064 if( ! NPVARIANT_IS_STRING(value) )
1066 /* return what we got so far */
1067 NPN_ReleaseVariantValue(&value);
1071 if( nOptions == capacity )
1074 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1077 /* failed to allocate more memory */
1078 NPN_ReleaseVariantValue(&value);
1079 /* return what we got so far */
1080 *i_options = nOptions;
1081 *ppsz_options = options;
1084 options = moreOptions;
1087 options[nOptions++] = stringValue(value);
1088 NPN_ReleaseVariantValue(&value);
1090 *i_options = nOptions;
1091 *ppsz_options = options;
1098 ** implementation of libvlc subtitle object
1101 const NPUTF8 * const LibvlcSubtitleNPObject::propertyNames[] =
1107 enum LibvlcSubtitleNPObjectPropertyIds
1112 COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
1114 RuntimeNPObject::InvokeResult
1115 LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
1117 /* is plugin still running */
1118 if( isPluginRunning() )
1120 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1121 libvlc_exception_t ex;
1122 libvlc_exception_init(&ex);
1124 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1125 RETURN_ON_EXCEPTION(this,ex);
1129 case ID_subtitle_track:
1131 /* get the current subtitle ID */
1132 int i_spu = libvlc_video_get_spu(p_md, &ex);
1133 RETURN_ON_EXCEPTION(this,ex);
1135 INT32_TO_NPVARIANT(i_spu, result);
1136 return INVOKERESULT_NO_ERROR;
1138 case ID_subtitle_count:
1140 /* get the number of subtitles available */
1141 int i_spu = libvlc_video_get_spu_count(p_md, &ex);
1142 RETURN_ON_EXCEPTION(this,ex);
1144 INT32_TO_NPVARIANT(i_spu, result);
1145 return INVOKERESULT_NO_ERROR;
1149 return INVOKERESULT_GENERIC_ERROR;
1152 RuntimeNPObject::InvokeResult
1153 LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
1155 /* is plugin still running */
1156 if( isPluginRunning() )
1158 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1159 libvlc_exception_t ex;
1160 libvlc_exception_init(&ex);
1162 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1163 RETURN_ON_EXCEPTION(this,ex);
1167 case ID_subtitle_track:
1169 if( isNumberValue(value) )
1171 /* set the new subtitle track to show */
1172 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1173 RETURN_ON_EXCEPTION(this,ex);
1175 return INVOKERESULT_NO_ERROR;
1177 return INVOKERESULT_INVALID_VALUE;
1181 return INVOKERESULT_GENERIC_ERROR;
1184 const NPUTF8 * const LibvlcSubtitleNPObject::methodNames[] =
1188 COUNTNAMES(LibvlcSubtitleNPObject,methodCount,methodNames);
1190 enum LibvlcSubtitleNPObjectMethodIds
1192 ID_subtitle_description
1195 RuntimeNPObject::InvokeResult
1196 LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
1197 uint32_t argCount, NPVariant &result)
1199 /* is plugin still running */
1200 if( isPluginRunning() )
1202 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1203 libvlc_exception_t ex;
1204 libvlc_exception_init(&ex);
1206 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1207 RETURN_ON_EXCEPTION(this,ex);
1211 case ID_subtitle_description:
1216 int i_spuID, i_limit, i;
1217 libvlc_track_description_t *p_spuDesc;
1219 /* get subtitles description */
1220 p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
1221 RETURN_ON_EXCEPTION(this,ex);
1223 return INVOKERESULT_GENERIC_ERROR;
1225 /* get the number of subtitle available */
1226 i_limit = libvlc_video_get_spu_count(p_md, &ex);
1227 RETURN_ON_EXCEPTION(this,ex);
1229 /* check if a number is given by the user
1230 * and get the subtitle number */
1231 if( isNumberValue(args[0]) )
1232 i_spuID = numberValue(args[0]);
1234 return INVOKERESULT_INVALID_VALUE;
1236 /* if bad number is given return invalid value */
1237 if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
1238 return INVOKERESULT_INVALID_VALUE;
1240 /* get the good spuDesc */
1241 for( i = 0 ; i < i_spuID ; i++ )
1243 p_spuDesc = p_spuDesc->p_next;
1245 psz_name = p_spuDesc->psz_name;
1247 /* return the name of the track chosen */
1248 return invokeResultString(psz_name, result);
1250 return INVOKERESULT_NO_SUCH_METHOD;
1253 return INVOKERESULT_NO_SUCH_METHOD;
1256 return INVOKERESULT_GENERIC_ERROR;
1260 ** implementation of libvlc video object
1263 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1275 enum LibvlcVideoNPObjectPropertyIds
1277 ID_video_fullscreen,
1280 ID_video_aspectratio,
1286 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1288 RuntimeNPObject::InvokeResult
1289 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1291 /* is plugin still running */
1292 if( isPluginRunning() )
1294 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1295 libvlc_exception_t ex;
1296 libvlc_exception_init(&ex);
1298 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1299 RETURN_ON_EXCEPTION(this,ex);
1303 case ID_video_fullscreen:
1305 int val = p_plugin->get_fullscreen(&ex);
1306 RETURN_ON_EXCEPTION(this,ex);
1307 BOOLEAN_TO_NPVARIANT(val, result);
1308 return INVOKERESULT_NO_ERROR;
1310 case ID_video_height:
1312 int val = libvlc_video_get_height(p_md, &ex);
1313 RETURN_ON_EXCEPTION(this,ex);
1314 INT32_TO_NPVARIANT(val, result);
1315 return INVOKERESULT_NO_ERROR;
1317 case ID_video_width:
1319 int val = libvlc_video_get_width(p_md, &ex);
1320 RETURN_ON_EXCEPTION(this,ex);
1321 INT32_TO_NPVARIANT(val, result);
1322 return INVOKERESULT_NO_ERROR;
1324 case ID_video_aspectratio:
1326 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1327 RETURN_ON_EXCEPTION(this,ex);
1329 return INVOKERESULT_GENERIC_ERROR;
1331 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1332 return INVOKERESULT_NO_ERROR;
1334 case ID_video_subtitle:
1336 int i_spu = libvlc_video_get_spu(p_md, &ex);
1337 RETURN_ON_EXCEPTION(this,ex);
1338 INT32_TO_NPVARIANT(i_spu, result);
1339 return INVOKERESULT_NO_ERROR;
1343 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1344 RETURN_ON_EXCEPTION(this,ex);
1346 return INVOKERESULT_GENERIC_ERROR;
1348 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1349 return INVOKERESULT_NO_ERROR;
1351 case ID_video_teletext:
1353 int i_page = libvlc_video_get_teletext(p_md, &ex);
1354 RETURN_ON_EXCEPTION(this,ex);
1355 INT32_TO_NPVARIANT(i_page, result);
1356 return INVOKERESULT_NO_ERROR;
1358 case ID_video_marquee:
1361 marqueeObj = NPN_CreateObject(_instance,
1362 RuntimeNPClass<LibvlcMarqueeNPObject>::getClass());
1363 OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
1364 return INVOKERESULT_NO_ERROR;
1368 return INVOKERESULT_GENERIC_ERROR;
1371 RuntimeNPObject::InvokeResult
1372 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1374 /* is plugin still running */
1375 if( isPluginRunning() )
1377 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1378 libvlc_exception_t ex;
1379 libvlc_exception_init(&ex);
1381 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1382 RETURN_ON_EXCEPTION(this,ex);
1386 case ID_video_fullscreen:
1388 if( ! NPVARIANT_IS_BOOLEAN(value) )
1390 return INVOKERESULT_INVALID_VALUE;
1393 int val = NPVARIANT_TO_BOOLEAN(value);
1394 p_plugin->set_fullscreen(val, &ex);
1395 RETURN_ON_EXCEPTION(this,ex);
1396 return INVOKERESULT_NO_ERROR;
1398 case ID_video_aspectratio:
1400 char *psz_aspect = NULL;
1402 if( ! NPVARIANT_IS_STRING(value) )
1404 return INVOKERESULT_INVALID_VALUE;
1407 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1410 return INVOKERESULT_GENERIC_ERROR;
1413 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1415 RETURN_ON_EXCEPTION(this,ex);
1417 return INVOKERESULT_NO_ERROR;
1419 case ID_video_subtitle:
1421 if( isNumberValue(value) )
1423 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1424 RETURN_ON_EXCEPTION(this,ex);
1426 return INVOKERESULT_NO_ERROR;
1428 return INVOKERESULT_INVALID_VALUE;
1432 char *psz_geometry = NULL;
1434 if( ! NPVARIANT_IS_STRING(value) )
1436 return INVOKERESULT_INVALID_VALUE;
1439 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1442 return INVOKERESULT_GENERIC_ERROR;
1445 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1447 RETURN_ON_EXCEPTION(this,ex);
1449 return INVOKERESULT_NO_ERROR;
1451 case ID_video_teletext:
1453 if( isNumberValue(value) )
1455 libvlc_video_set_teletext(p_md, numberValue(value), &ex);
1456 RETURN_ON_EXCEPTION(this,ex);
1458 return INVOKERESULT_NO_ERROR;
1460 return INVOKERESULT_INVALID_VALUE;
1464 return INVOKERESULT_GENERIC_ERROR;
1467 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1471 "deinterlaceEnable",
1472 "deinterlaceDisable"
1474 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1476 enum LibvlcVideoNPObjectMethodIds
1478 ID_video_togglefullscreen,
1479 ID_video_toggleteletext,
1480 ID_video_deinterlaceenable,
1481 ID_video_deinterlacedisable
1484 RuntimeNPObject::InvokeResult
1485 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1486 uint32_t argCount, NPVariant &result)
1488 /* is plugin still running */
1489 if( isPluginRunning() )
1491 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1492 libvlc_exception_t ex;
1493 libvlc_exception_init(&ex);
1495 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1496 RETURN_ON_EXCEPTION(this,ex);
1500 case ID_video_togglefullscreen:
1504 p_plugin->toggle_fullscreen(&ex);
1505 RETURN_ON_EXCEPTION(this,ex);
1506 VOID_TO_NPVARIANT(result);
1507 return INVOKERESULT_NO_ERROR;
1509 return INVOKERESULT_NO_SUCH_METHOD;
1511 case ID_video_toggleteletext:
1515 libvlc_toggle_teletext(p_md, &ex);
1516 RETURN_ON_EXCEPTION(this,ex);
1517 VOID_TO_NPVARIANT(result);
1518 return INVOKERESULT_NO_ERROR;
1520 return INVOKERESULT_NO_SUCH_METHOD;
1522 case ID_video_deinterlacedisable:
1524 libvlc_video_set_deinterlace(p_md, 0, "", &ex);
1525 RETURN_ON_EXCEPTION(this,ex);
1526 return INVOKERESULT_NO_ERROR;
1528 case ID_video_deinterlaceenable:
1532 if( NPVARIANT_IS_STRING( args[0] ) )
1534 /* get deinterlace mode from the user */
1535 char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1536 /* enable deinterlace filter if possible */
1537 libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
1539 RETURN_ON_EXCEPTION(this,ex);
1540 return INVOKERESULT_NO_ERROR;
1544 return INVOKERESULT_INVALID_VALUE;
1549 return INVOKERESULT_NO_SUCH_METHOD;
1552 return INVOKERESULT_GENERIC_ERROR;
1556 ** implementation of libvlc marquee object
1559 const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
1563 enum LibvlcMarqueeNPObjectPropertyIds
1566 COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
1568 RuntimeNPObject::InvokeResult
1569 LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
1571 /* is plugin still running */
1572 if( isPluginRunning() )
1574 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1575 libvlc_exception_t ex;
1576 libvlc_exception_init(&ex);
1578 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1579 RETURN_ON_EXCEPTION(this,ex);
1585 return INVOKERESULT_GENERIC_ERROR;
1588 RuntimeNPObject::InvokeResult
1589 LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
1591 /* is plugin still running */
1592 if( isPluginRunning() )
1594 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1595 libvlc_exception_t ex;
1596 libvlc_exception_init(&ex);
1598 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1599 RETURN_ON_EXCEPTION(this,ex);
1605 return INVOKERESULT_GENERIC_ERROR;
1608 const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
1622 COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
1624 enum LibvlcMarqueeNPObjectMethodIds
1630 ID_marquee_position,
1639 RuntimeNPObject::InvokeResult
1640 LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
1641 uint32_t argCount, NPVariant &result)
1643 /* is plugin still running */
1644 if( isPluginRunning() )
1646 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1647 libvlc_exception_t ex;
1648 libvlc_exception_init(&ex);
1650 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1651 RETURN_ON_EXCEPTION(this,ex);
1655 case ID_marquee_enable:
1657 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
1658 RETURN_ON_EXCEPTION(this,ex);
1659 return INVOKERESULT_NO_ERROR;
1661 case ID_marquee_disable:
1663 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
1664 RETURN_ON_EXCEPTION(this,ex);
1665 return INVOKERESULT_NO_ERROR;
1667 case ID_marquee_color:
1671 if( NPVARIANT_IS_INT32( args[0] ) )
1673 int i_color = NPVARIANT_TO_INT32( args[0] );
1674 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, i_color, &ex);
1675 RETURN_ON_EXCEPTION(this,ex);
1676 return INVOKERESULT_NO_ERROR;
1679 return INVOKERESULT_GENERIC_ERROR;
1681 return INVOKERESULT_NO_SUCH_METHOD;
1683 case ID_marquee_opacity:
1687 if( NPVARIANT_IS_INT32( args[0] ) )
1689 int i_opacity = NPVARIANT_TO_INT32( args[0] );
1690 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, i_opacity, &ex);
1691 RETURN_ON_EXCEPTION(this,ex);
1692 return INVOKERESULT_NO_ERROR;
1695 return INVOKERESULT_GENERIC_ERROR;
1697 return INVOKERESULT_NO_SUCH_METHOD;
1699 case ID_marquee_position:
1703 if( NPVARIANT_IS_INT32( args[0] ) )
1705 int i_position = NPVARIANT_TO_INT32( args[0] );
1706 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, i_position, &ex);
1707 RETURN_ON_EXCEPTION(this,ex);
1708 return INVOKERESULT_NO_ERROR;
1711 return INVOKERESULT_GENERIC_ERROR;
1713 return INVOKERESULT_NO_SUCH_METHOD;
1715 case ID_marquee_refresh:
1719 if( NPVARIANT_IS_INT32( args[0] ) )
1721 int i_refresh = NPVARIANT_TO_INT32( args[0] );
1722 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, i_refresh, &ex);
1723 RETURN_ON_EXCEPTION(this,ex);
1724 return INVOKERESULT_NO_ERROR;
1727 return INVOKERESULT_GENERIC_ERROR;
1729 return INVOKERESULT_NO_SUCH_METHOD;
1731 case ID_marquee_size:
1735 if( NPVARIANT_IS_INT32( args[0] ) )
1737 int i_size = NPVARIANT_TO_INT32( args[0] );
1738 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, i_size, &ex);
1739 RETURN_ON_EXCEPTION(this,ex);
1740 return INVOKERESULT_NO_ERROR;
1743 return INVOKERESULT_GENERIC_ERROR;
1745 return INVOKERESULT_NO_SUCH_METHOD;
1747 case ID_marquee_text:
1751 if( NPVARIANT_IS_STRING( args[0] ) )
1753 char *psz_text = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1754 libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
1755 RETURN_ON_EXCEPTION(this,ex);
1757 return INVOKERESULT_NO_ERROR;
1760 return INVOKERESULT_GENERIC_ERROR;
1762 return INVOKERESULT_NO_SUCH_METHOD;
1764 case ID_marquee_timeout:
1768 if( NPVARIANT_IS_INT32( args[0] ) )
1770 int i_timeout = NPVARIANT_TO_INT32( args[0] );
1771 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, i_timeout, &ex);
1772 RETURN_ON_EXCEPTION(this,ex);
1773 return INVOKERESULT_NO_ERROR;
1776 return INVOKERESULT_GENERIC_ERROR;
1778 return INVOKERESULT_NO_SUCH_METHOD;
1784 if( NPVARIANT_IS_INT32( args[0] ) )
1786 int i_x = NPVARIANT_TO_INT32( args[0] );
1787 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, i_x, &ex);
1788 RETURN_ON_EXCEPTION(this,ex);
1789 return INVOKERESULT_NO_ERROR;
1792 return INVOKERESULT_GENERIC_ERROR;
1794 return INVOKERESULT_NO_SUCH_METHOD;
1800 if( NPVARIANT_IS_INT32( args[0] ) )
1802 int i_y = NPVARIANT_TO_INT32( args[0] );
1803 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, i_y, &ex);
1804 RETURN_ON_EXCEPTION(this,ex);
1805 return INVOKERESULT_NO_ERROR;
1808 return INVOKERESULT_GENERIC_ERROR;
1810 return INVOKERESULT_NO_SUCH_METHOD;
1813 return INVOKERESULT_NO_SUCH_METHOD;
1816 return INVOKERESULT_GENERIC_ERROR;