Mozilla : use \n
[vlc.git] / projects / mozilla / control / npovlc.cpp
1 /*****************************************************************************
2  * npovlc.cpp: deprecated VLC apis implemented in late XPCOM interface
3  *****************************************************************************
4  * Copyright (C) 2002-2006 the VideoLAN team
5  *
6  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #include "config.h"
24
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc/vlc.h>
34
35 /* Mozilla stuff */
36 #ifdef HAVE_MOZILLA_CONFIG_H
37 #   include <mozilla-config.h>
38 #endif
39
40 #include "npovlc.h"
41 #include "vlcplugin.h"
42
43 /*
44 ** implementation of vlc root object
45 */
46
47 const NPUTF8 * const VlcNPObject::propertyNames[] =
48 {
49     /* no properties */
50 };
51
52 const int VlcNPObject::propertyCount = sizeof(VlcNPObject::propertyNames)/sizeof(NPUTF8 *);
53
54 const NPUTF8 * const VlcNPObject::methodNames[] =
55 {
56     "play",                 /* deprecated */
57     "pause",                /* deprecated */
58     "stop",                 /* deprecated */
59     "fullscreen",           /* deprecated */
60     "set_volume",           /* deprecated */
61     "get_volume",           /* deprecated */
62     "mute",                 /* deprecated */
63     "get_int_variable",     /* deprecated */
64     "set_int_variable",     /* deprecated */
65     "get_bool_variable",    /* deprecated */
66     "set_bool_variable",    /* deprecated */
67     "get_str_variable",     /* deprecated */
68     "set_str_variable",     /* deprecated */
69     "clear_playlist",       /* deprecated */
70     "add_item",             /* deprecated */
71     "next",                 /* deprecated */
72     "previous",             /* deprecated */
73     "isplaying",            /* deprecated */
74     "get_length",           /* deprecated */
75     "get_position",         /* deprecated */
76     "get_time",             /* deprecated */
77     "seek",                 /* deprecated */
78 };
79
80 enum VlcNPObjectMethodIds
81 {
82     ID_play = 0,
83     ID_pause,
84     ID_stop,
85     ID_fullscreen,
86     ID_set_volume,
87     ID_get_volume,
88     ID_mute,
89     ID_get_int_variable,
90     ID_set_int_variable,
91     ID_get_bool_variable,
92     ID_set_bool_variable,
93     ID_get_str_variable,
94     ID_set_str_variable,
95     ID_clear_playlist,
96     ID_add_item,
97     ID_next,
98     ID_previous,
99     ID_isplaying,
100     ID_get_length,
101     ID_get_position,
102     ID_get_time,
103     ID_seek,
104 };
105
106 const int VlcNPObject::methodCount = sizeof(VlcNPObject::methodNames)/sizeof(NPUTF8 *);
107
108 RuntimeNPObject::InvokeResult VlcNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
109 {
110     VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
111     if( p_plugin )
112     {
113         libvlc_exception_t ex;
114         libvlc_exception_init(&ex);
115
116         switch( index )
117         {
118             case ID_play: /* deprecated */
119                 if( argCount == 0 )
120                 {
121                     libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
122                     if( libvlc_exception_raised(&ex) )
123                     {
124                         NPN_SetException(this, libvlc_exception_get_message(&ex));
125                         libvlc_exception_clear(&ex);
126                         return INVOKERESULT_GENERIC_ERROR;
127                     }
128                     else
129                     {
130                         VOID_TO_NPVARIANT(result);
131                         return INVOKERESULT_NO_ERROR;
132                     }
133                 }
134                 return INVOKERESULT_NO_SUCH_METHOD;
135             case ID_pause: /* deprecated */
136                 if( argCount == 0 )
137                 {
138                     libvlc_playlist_pause(p_plugin->getVLC(), &ex);
139                     if( libvlc_exception_raised(&ex) )
140                     {
141                         NPN_SetException(this, libvlc_exception_get_message(&ex));
142                         libvlc_exception_clear(&ex);
143                         return INVOKERESULT_GENERIC_ERROR;
144                     }
145                     else
146                     {
147                         VOID_TO_NPVARIANT(result);
148                         return INVOKERESULT_NO_ERROR;
149                     }
150                 }
151                 return INVOKERESULT_NO_SUCH_METHOD;
152             case ID_stop: /* deprecated */
153                 if( argCount == 0 )
154                 {
155                     libvlc_playlist_stop(p_plugin->getVLC(), &ex);
156                     if( libvlc_exception_raised(&ex) )
157                     {
158                         NPN_SetException(this, libvlc_exception_get_message(&ex));
159                         libvlc_exception_clear(&ex);
160                         return INVOKERESULT_GENERIC_ERROR;
161                     }
162                     else
163                     {
164                         VOID_TO_NPVARIANT(result);
165                         return INVOKERESULT_NO_ERROR;
166                     }
167                 }
168                 return INVOKERESULT_NO_SUCH_METHOD;
169             case ID_fullscreen: /* deprecated */
170                 if( argCount == 0 )
171                 {
172                     libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
173                     if( p_md )
174                     {
175                         libvlc_toggle_fullscreen(p_md, &ex);
176                         libvlc_media_player_release(p_md);
177                         if( libvlc_exception_raised(&ex) )
178                         {
179                             NPN_SetException(this, libvlc_exception_get_message(&ex));
180                             libvlc_exception_clear(&ex);
181                             return INVOKERESULT_GENERIC_ERROR;
182                         }
183                         else
184                         {
185                             VOID_TO_NPVARIANT(result);
186                             return INVOKERESULT_NO_ERROR;
187                         }
188                     }
189                     else
190                     {
191                         /* cannot get input, probably not playing */
192                         if( libvlc_exception_raised(&ex) )
193                         {
194                             NPN_SetException(this, libvlc_exception_get_message(&ex));
195                             libvlc_exception_clear(&ex);
196                         }
197                         return INVOKERESULT_GENERIC_ERROR;
198                     }
199                 }
200                 return INVOKERESULT_NO_SUCH_METHOD;
201             case ID_set_volume: /* deprecated */
202                 if( (argCount == 1) && isNumberValue(args[0]) )
203                 {
204                     libvlc_audio_set_volume(p_plugin->getVLC(), numberValue(args[0]), &ex);
205                     if( libvlc_exception_raised(&ex) )
206                     {
207                         NPN_SetException(this, libvlc_exception_get_message(&ex));
208                         libvlc_exception_clear(&ex);
209                         return INVOKERESULT_GENERIC_ERROR;
210                     }
211                     else
212                     {
213                         VOID_TO_NPVARIANT(result);
214                         return INVOKERESULT_NO_ERROR;
215                     }
216                 }
217                 return INVOKERESULT_NO_SUCH_METHOD;
218             case ID_get_volume: /* deprecated */
219                 if( argCount == 0 )
220                 {
221                     int val = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
222                     if( libvlc_exception_raised(&ex) )
223                     {
224                         NPN_SetException(this, libvlc_exception_get_message(&ex));
225                         libvlc_exception_clear(&ex);
226                         return INVOKERESULT_GENERIC_ERROR;
227                     }
228                     else
229                     {
230                         INT32_TO_NPVARIANT(val, result);
231                         return INVOKERESULT_NO_ERROR;
232                     }
233                 }
234                 return INVOKERESULT_NO_SUCH_METHOD;
235             case ID_mute: /* deprecated */
236                 if( argCount == 0 )
237                 {
238                     libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
239                     if( libvlc_exception_raised(&ex) )
240                     {
241                         NPN_SetException(this, libvlc_exception_get_message(&ex));
242                         libvlc_exception_clear(&ex);
243                         return INVOKERESULT_GENERIC_ERROR;
244                     }
245                     else
246                     {
247                         VOID_TO_NPVARIANT(result);
248                         return INVOKERESULT_NO_ERROR;
249                     }
250                 }
251                 return INVOKERESULT_NO_SUCH_METHOD;
252             case ID_get_int_variable: /* deprecated */
253                 if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
254                 {
255                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
256                     if( s )
257                     {
258                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
259                         vlc_value_t val;
260                         if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
261                         {
262                             delete s;
263                             INT32_TO_NPVARIANT(val.i_int, result);
264                             return INVOKERESULT_NO_ERROR;
265                         }
266                         else
267                         {
268                             delete s;
269                             return INVOKERESULT_INVALID_ARGS;
270                         }
271                     }
272                     else
273                         return INVOKERESULT_OUT_OF_MEMORY;
274                 }
275                 return INVOKERESULT_NO_SUCH_METHOD;
276             case ID_set_int_variable: /* deprecated */
277                 if( (argCount == 2)
278                     && NPVARIANT_IS_STRING(args[0])
279                     && isNumberValue(args[1]) )
280                 {
281                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
282                     if( s )
283                     {
284                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
285                         vlc_value_t val;
286                         val.i_int = numberValue(args[1]);
287                         if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
288                         {
289                             delete s;
290                             VOID_TO_NPVARIANT(result);
291                             return INVOKERESULT_NO_ERROR;
292                         }
293                         else
294                         {
295                             delete s;
296                             return INVOKERESULT_INVALID_ARGS;
297                         }
298                     }
299                     else
300                         return INVOKERESULT_OUT_OF_MEMORY;
301                 }
302                 return INVOKERESULT_NO_SUCH_METHOD;
303             case ID_get_bool_variable: /* deprecated */
304                 if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
305                 {
306                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
307                     if( s )
308                     {
309                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
310                         vlc_value_t val;
311                         if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
312                         {
313                             delete s;
314                             BOOLEAN_TO_NPVARIANT(val.b_bool, result);
315                             return INVOKERESULT_NO_ERROR;
316                         }
317                         else
318                         {
319                             delete s;
320                             return INVOKERESULT_INVALID_ARGS;
321                         }
322                     }
323                     else
324                         return INVOKERESULT_OUT_OF_MEMORY;
325                 }
326                 return INVOKERESULT_NO_SUCH_METHOD;
327             case ID_set_bool_variable: /* deprecated */
328                 if( (argCount == 2)
329                     && NPVARIANT_IS_STRING(args[0])
330                     && NPVARIANT_IS_BOOLEAN(args[1]) )
331                 {
332                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
333                     if( s )
334                     {
335                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
336                         vlc_value_t val;
337                         val.b_bool = NPVARIANT_TO_BOOLEAN(args[1]);
338                         if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
339                         {
340                             delete s;
341                             VOID_TO_NPVARIANT(result);
342                             return INVOKERESULT_NO_ERROR;
343                         }
344                         else
345                         {
346                             delete s;
347                             return INVOKERESULT_INVALID_ARGS;
348                         }
349                     }
350                     else
351                         return INVOKERESULT_OUT_OF_MEMORY;
352                 }
353                 return INVOKERESULT_NO_SUCH_METHOD;
354             case ID_get_str_variable: /* deprecated */
355                 if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
356                 {
357                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
358                     if( s )
359                     {
360                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
361                         vlc_value_t val;
362                         if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
363                         {
364                             delete s;
365                             if( val.psz_string )
366                             {
367                                 int len = strlen(val.psz_string);
368                                 NPUTF8 *retval = (NPUTF8 *)NPN_MemAlloc(len);
369                                 if( retval )
370                                 {
371                                     memcpy(retval, val.psz_string, len);
372                                     STRINGN_TO_NPVARIANT(retval, len, result);
373                                     free(val.psz_string);
374                                     return INVOKERESULT_NO_ERROR;
375                                 }
376                                 else
377                                 {
378                                     return INVOKERESULT_OUT_OF_MEMORY;
379                                 }
380                             }
381                             else
382                             {
383                                 /* null string */
384                                 NULL_TO_NPVARIANT(result);
385                                 return INVOKERESULT_NO_ERROR;
386                             }
387                         }
388                         else
389                         {
390                             delete s;
391                             return INVOKERESULT_INVALID_ARGS;
392                         }
393                     }
394                     else
395                         return INVOKERESULT_OUT_OF_MEMORY;
396                 }
397                 return INVOKERESULT_NO_SUCH_METHOD;
398             case ID_set_str_variable: /* deprecated */
399                 if( (argCount == 2)
400                     && NPVARIANT_IS_STRING(args[0])
401                     && NPVARIANT_IS_STRING(args[1]) )
402                 {
403                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
404                     if( s )
405                     {
406                         int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
407                         vlc_value_t val;
408                         val.psz_string = stringValue(NPVARIANT_TO_STRING(args[1]));
409                         if( val.psz_string )
410                         {
411                             if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
412                             {
413                                 delete s;
414                                 delete val.psz_string;
415                                 VOID_TO_NPVARIANT(result);
416                                 return INVOKERESULT_NO_ERROR;
417                             }
418                             else
419                             {
420                                 delete s;
421                                 delete val.psz_string;
422                                 return INVOKERESULT_INVALID_ARGS;
423                             }
424                         }
425                         else
426                         {
427                             delete s;
428                             return INVOKERESULT_OUT_OF_MEMORY;
429                         }
430                     }
431                     else
432                         return INVOKERESULT_OUT_OF_MEMORY;
433                 }
434                 return INVOKERESULT_NO_SUCH_METHOD;
435             case ID_clear_playlist: /* deprecated */
436                 if( argCount == 0 )
437                 {
438                     libvlc_playlist_clear(p_plugin->getVLC(), &ex);
439                     if( libvlc_exception_raised(&ex) )
440                     {
441                         NPN_SetException(this, libvlc_exception_get_message(&ex));
442                         libvlc_exception_clear(&ex);
443                         return INVOKERESULT_GENERIC_ERROR;
444                     }
445                     else
446                     {
447                         VOID_TO_NPVARIANT(result);
448                         return INVOKERESULT_NO_ERROR;
449                     }
450                 }
451                 return INVOKERESULT_NO_SUCH_METHOD;
452             case ID_add_item: /* deprecated */
453                 if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
454                 {
455                     char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
456                     if( s )
457                     {
458                         char *url = p_plugin->getAbsoluteURL(s);
459                         delete s;
460                         if( ! url )
461                             // what happened ?
462                             return INVOKERESULT_GENERIC_ERROR;
463                              
464                         int item = libvlc_playlist_add(p_plugin->getVLC(), url, NULL, &ex);
465                         free(url);
466                         if( libvlc_exception_raised(&ex) )
467                         {
468                             NPN_SetException(this, libvlc_exception_get_message(&ex));
469                             libvlc_exception_clear(&ex);
470                             return INVOKERESULT_GENERIC_ERROR;
471                         }
472                         else
473                         {
474                             INT32_TO_NPVARIANT(item, result);
475                             return INVOKERESULT_NO_ERROR;
476                         }
477                     }
478                     else
479                         return INVOKERESULT_OUT_OF_MEMORY;
480                 }
481                 return INVOKERESULT_NO_SUCH_METHOD;
482             case ID_next: /* deprecated */
483                 if( argCount == 0 )
484                 {
485                     libvlc_playlist_next(p_plugin->getVLC(), &ex);
486                     if( libvlc_exception_raised(&ex) )
487                     {
488                         NPN_SetException(this, libvlc_exception_get_message(&ex));
489                         libvlc_exception_clear(&ex);
490                         return INVOKERESULT_GENERIC_ERROR;
491                     }
492                     else
493                     {
494                         VOID_TO_NPVARIANT(result);
495                         return INVOKERESULT_NO_ERROR;
496                     }
497                 }
498                 return INVOKERESULT_NO_SUCH_METHOD;
499             case ID_previous: /* deprecated */
500                 if( argCount == 0 )
501                 {
502                     libvlc_playlist_prev(p_plugin->getVLC(), &ex);
503                     if( libvlc_exception_raised(&ex) )
504                     {
505                         NPN_SetException(this, libvlc_exception_get_message(&ex));
506                         libvlc_exception_clear(&ex);
507                         return INVOKERESULT_GENERIC_ERROR;
508                     }
509                     else
510                     {
511                         VOID_TO_NPVARIANT(result);
512                         return INVOKERESULT_NO_ERROR;
513                     }
514                 }
515                 return INVOKERESULT_NO_SUCH_METHOD;
516             case ID_isplaying: /* deprecated */
517                 if( argCount == 0 )
518                 {
519                     int isplaying = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
520                     if( libvlc_exception_raised(&ex) )
521                     {
522                         NPN_SetException(this, libvlc_exception_get_message(&ex));
523                         libvlc_exception_clear(&ex);
524                         return INVOKERESULT_GENERIC_ERROR;
525                     }
526                     else
527                     {
528                         BOOLEAN_TO_NPVARIANT(isplaying, result);
529                         return INVOKERESULT_NO_ERROR;
530                     }
531                 }
532                 return INVOKERESULT_NO_SUCH_METHOD;
533             case ID_get_length: /* deprecated */
534                 if( argCount == 0 )
535                 {
536                     libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
537                     if( p_md )
538                     {
539                         vlc_int64_t val = libvlc_media_player_get_length(p_md, &ex);
540                         libvlc_media_player_release(p_md);
541                         if( libvlc_exception_raised(&ex) )
542                         {
543                             NPN_SetException(this, libvlc_exception_get_message(&ex));
544                             libvlc_exception_clear(&ex);
545                             return INVOKERESULT_GENERIC_ERROR;
546                         }
547                         else
548                         {
549                             INT32_TO_NPVARIANT((uint32_t)(val/1000LL), result);
550                             return INVOKERESULT_NO_ERROR;
551                         }
552                     }
553                     else
554                     {
555                         /* cannot get input, probably not playing */
556                         if( libvlc_exception_raised(&ex) )
557                         {
558                             NPN_SetException(this, libvlc_exception_get_message(&ex));
559                             libvlc_exception_clear(&ex);
560                         }
561                         return INVOKERESULT_GENERIC_ERROR;
562                     }
563                 }
564                 return INVOKERESULT_NO_SUCH_METHOD;
565             case ID_get_position: /* deprecated */
566                 if( argCount == 0 )
567                 {
568                     libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
569                     if( p_md )
570                     {
571                         float val = libvlc_media_player_get_position(p_md, &ex);
572                         libvlc_media_player_release(p_md);
573                         if( libvlc_exception_raised(&ex) )
574                         {
575                             NPN_SetException(this, libvlc_exception_get_message(&ex));
576                             libvlc_exception_clear(&ex);
577                             return INVOKERESULT_GENERIC_ERROR;
578                         }
579                         else
580                         {
581                             DOUBLE_TO_NPVARIANT((double)val, result);
582                             return INVOKERESULT_NO_ERROR;
583                         }
584                     }
585                     else
586                     {
587                         /* cannot get input, probably not playing */
588                         if( libvlc_exception_raised(&ex) )
589                         {
590                             NPN_SetException(this, libvlc_exception_get_message(&ex));
591                             libvlc_exception_clear(&ex);
592                         }
593                         return INVOKERESULT_GENERIC_ERROR;
594                     }
595                 }
596                 return INVOKERESULT_NO_SUCH_METHOD;
597             case ID_get_time: /* deprecated */
598                 if( argCount == 0 )
599                 {
600                     libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
601                     if( p_md )
602                     {
603                         vlc_int64_t val = libvlc_media_player_get_time(p_md, &ex);
604                         libvlc_media_player_release(p_md);
605                         if( libvlc_exception_raised(&ex) )
606                         {
607                             NPN_SetException(this, libvlc_exception_get_message(&ex));
608                             libvlc_exception_clear(&ex);
609                             return INVOKERESULT_GENERIC_ERROR;
610                         }
611                         else
612                         {
613                             DOUBLE_TO_NPVARIANT((uint32_t)(val/1000LL), result);
614                             return INVOKERESULT_NO_ERROR;
615                         }
616                     }
617                     else
618                     {
619                         /* cannot get input, probably not playing */
620                         if( libvlc_exception_raised(&ex) )
621                         {
622                             NPN_SetException(this, libvlc_exception_get_message(&ex));
623                             libvlc_exception_clear(&ex);
624                         }
625                         return INVOKERESULT_GENERIC_ERROR;
626                     }
627                 }
628                 return INVOKERESULT_NO_SUCH_METHOD;
629             case ID_seek: /* deprecated */
630                 if( (argCount == 2)
631                   && isNumberValue(args[0])
632                   && NPVARIANT_IS_BOOLEAN(args[1]) )
633                 {
634                     libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
635                     if( p_md )
636                     {
637                         vlc_int64_t pos = 0;
638                         if( NPVARIANT_IS_INT32(args[0]) )
639                             pos = (vlc_int64_t)NPVARIANT_TO_INT32(args[0]);
640                         else
641                             pos = (vlc_int64_t)NPVARIANT_TO_DOUBLE(args[0]);
642
643                         if( NPVARIANT_TO_BOOLEAN(args[1]) )
644                         {
645                             /* relative seek */
646                             vlc_int64_t from = libvlc_media_player_get_time(p_md, &ex);
647                             if( libvlc_exception_raised(&ex) )
648                             {
649                                 libvlc_media_player_release(p_md);
650                                 NPN_SetException(this, libvlc_exception_get_message(&ex));
651                                 libvlc_exception_clear(&ex);
652                                 return INVOKERESULT_GENERIC_ERROR;
653                             }
654                             pos += from;
655                         }
656                         /* jump to time */
657                         libvlc_media_player_set_time(p_md, pos, &ex);
658                         libvlc_media_player_release(p_md);
659                         if( libvlc_exception_raised(&ex) )
660                         {
661                             NPN_SetException(this, libvlc_exception_get_message(&ex));
662                             libvlc_exception_clear(&ex);
663                             return INVOKERESULT_GENERIC_ERROR;
664                         }
665                         VOID_TO_NPVARIANT(result);
666                         return INVOKERESULT_NO_ERROR;
667                     }
668                     else
669                     {
670                         /* cannot get input, probably not playing */
671                         if( libvlc_exception_raised(&ex) )
672                         {
673                             NPN_SetException(this, libvlc_exception_get_message(&ex));
674                             libvlc_exception_clear(&ex);
675                         }
676                         return INVOKERESULT_GENERIC_ERROR;
677                     }
678                 }
679                 return INVOKERESULT_NO_SUCH_METHOD;
680             default:
681                 return INVOKERESULT_NO_SUCH_METHOD;
682         }
683     }
684     return INVOKERESULT_GENERIC_ERROR;
685 }
686