#include "vlcplugin.h"
#include "npolibvlc.h"
+/*
+** Local helper macros and function
+*/
#define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
+#define RETURN_ON_EXCEPTION(ex) \
+ do { if( libvlc_exception_raised(&ex) ) \
+ { \
+ NPN_SetException(this, libvlc_exception_get_message(&ex)); \
+ libvlc_exception_clear(&ex); \
+ return INVOKERESULT_GENERIC_ERROR; \
+ } } while(false)
/*
** implementation of libvlc root object
case ID_audio_mute:
{
bool muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR;
}
case ID_audio_volume:
{
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR;
}
{
libvlc_media_player_t *p_md =
libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
int track = libvlc_audio_get_track(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(track, result);
return INVOKERESULT_NO_ERROR;
}
case ID_audio_channel:
{
int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(channel, result);
return INVOKERESULT_NO_ERROR;
}
{
libvlc_audio_set_mute(p_plugin->getVLC(),
NPVARIANT_TO_BOOLEAN(value), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
{
libvlc_audio_set_volume(p_plugin->getVLC(),
numberValue(value), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
{
libvlc_media_player_t *p_md =
libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
libvlc_audio_set_track(p_md,
numberValue(value), &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
{
libvlc_audio_set_channel(p_plugin->getVLC(),
numberValue(value), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
if( argCount == 0 )
{
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
{
double val = (double)libvlc_media_player_get_length(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
double val = libvlc_media_player_get_position(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
double val = (double)libvlc_media_player_get_time(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
int val = libvlc_media_player_get_state(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
float val = libvlc_media_player_get_rate(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
double val = libvlc_media_player_get_fps(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
bool val = libvlc_media_player_has_vout(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
libvlc_media_player_t *p_md =
libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
switch( index )
{
float val = (float)NPVARIANT_TO_DOUBLE(value);
libvlc_media_player_set_position(p_md, val, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
case ID_input_time:
libvlc_media_player_set_time(p_md, val, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
case ID_input_rate:
libvlc_media_player_set_rate(p_md, val, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
default:
BOOLEAN_TO_NPVARIANT(
libvlc_log_iterator_has_next(_p_iter, &ex), result );
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
else
{
buffer.sizeof_msg = sizeof(buffer);
libvlc_log_iterator_next(_p_iter, &buffer, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
+ RETURN_ON_EXCEPTION(ex);
+
+ LibvlcMessageNPObject* message =
+ static_cast<LibvlcMessageNPObject*>(
+ NPN_CreateObject(_instance, RuntimeNPClass<
+ LibvlcMessageNPObject>::getClass()));
+ if( message )
{
- LibvlcMessageNPObject* message =
- static_cast<LibvlcMessageNPObject*>(
- NPN_CreateObject(_instance, RuntimeNPClass<
- LibvlcMessageNPObject>::getClass()));
- if( message )
- {
- message->setMessage(buffer);
- OBJECT_TO_NPVARIANT(message, result);
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_OUT_OF_MEMORY;
+ message->setMessage(buffer);
+ OBJECT_TO_NPVARIANT(message, result);
+ return INVOKERESULT_NO_ERROR;
}
+ return INVOKERESULT_OUT_OF_MEMORY;
}
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_exception_init(&ex);
INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
else
{
if( p_log )
{
libvlc_log_clear(p_log, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
return INVOKERESULT_NO_ERROR;
}
{
INT32_TO_NPVARIANT( libvlc_get_log_verbosity(
p_plugin->getVLC(), &ex), result);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
else
{
if( !p_log )
{
p_log = libvlc_log_open(p_libvlc, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
p_plugin->setLog(p_log);
}
libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
else if( p_log )
{
/* close log when verbosity is set to -1 */
p_plugin->setLog(NULL);
libvlc_log_close(p_log, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
}
return INVOKERESULT_NO_ERROR;
}
libvlc_playlist_lock(p_plugin->getVLC());
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
libvlc_playlist_unlock(p_plugin->getVLC());
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
if( argCount == 0 )
{
libvlc_playlist_clear(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlistitems_remove:
{
libvlc_playlist_delete_item(p_plugin->getVLC(),
numberValue(args[0]), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
libvlc_playlist_lock(p_plugin->getVLC());
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
libvlc_playlist_unlock(p_plugin->getVLC());
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
libvlc_playlist_lock(p_plugin->getVLC());
int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
libvlc_playlist_unlock(p_plugin->getVLC());
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
}
free(ppsz_options);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- INT32_TO_NPVARIANT(item, result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ INT32_TO_NPVARIANT(item, result);
+ return INVOKERESULT_NO_ERROR;
}
case ID_playlist_play:
if( argCount == 0 )
{
libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_playItem:
{
libvlc_playlist_play(p_plugin->getVLC(),
numberValue(args[0]), 0, NULL, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_togglepause:
if( argCount == 0 )
{
libvlc_playlist_pause(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_stop:
if( argCount == 0 )
{
libvlc_playlist_stop(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_next:
if( argCount == 0 )
{
libvlc_playlist_next(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_prev:
if( argCount == 0 )
{
libvlc_playlist_prev(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_clear: /* deprecated */
if( argCount == 0 )
{
libvlc_playlist_clear(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlist_removeitem: /* deprecated */
{
libvlc_playlist_delete_item(p_plugin->getVLC(),
numberValue(args[0]), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
switch( index )
{
{
int val = libvlc_get_fullscreen(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
int val = libvlc_video_get_height(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
int val = libvlc_video_get_width(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
{
NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
if( !psz_aspect )
return INVOKERESULT_GENERIC_ERROR;
{
int i_spu = libvlc_video_get_spu(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(i_spu, result);
return INVOKERESULT_NO_ERROR;
}
{
NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
if( !psz_geometry )
return INVOKERESULT_GENERIC_ERROR;
{
int i_page = libvlc_video_get_teletext(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
INT32_TO_NPVARIANT(i_page, result);
return INVOKERESULT_NO_ERROR;
}
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
switch( index )
{
libvlc_set_fullscreen(p_md, val, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
return INVOKERESULT_NO_ERROR;
}
case ID_video_aspectratio:
libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
free(psz_aspect);
libvlc_media_player_release(p_md);
+ RETURN_ON_EXCEPTION(ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
return INVOKERESULT_NO_ERROR;
}
case ID_video_subtitle:
libvlc_video_set_spu(p_md,
numberValue(value), &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+
return INVOKERESULT_NO_ERROR;
}
libvlc_media_player_release(p_md);
libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
free(psz_geometry);
libvlc_media_player_release(p_md);
+ RETURN_ON_EXCEPTION(ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
return INVOKERESULT_NO_ERROR;
}
case ID_video_teletext:
libvlc_video_set_teletext(p_md,
numberValue(value), &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
+
return INVOKERESULT_NO_ERROR;
}
libvlc_media_player_release(p_md);
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
+ RETURN_ON_EXCEPTION(ex);
switch( index )
{
{
libvlc_toggle_fullscreen(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
- }
- else
- {
- /* cannot get md, probably not playing */
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- }
- return INVOKERESULT_GENERIC_ERROR;
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_video_toggleteletext:
{
libvlc_toggle_teletext(p_md, &ex);
libvlc_media_player_release(p_md);
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return INVOKERESULT_GENERIC_ERROR;
- }
- else
- {
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
- }
- else
- {
- /* cannot get md, probably not playing */
- if( libvlc_exception_raised(&ex) )
- {
- NPN_SetException(this, libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- }
- return INVOKERESULT_GENERIC_ERROR;
+ RETURN_ON_EXCEPTION(ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default: