}
}
-const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
{
"audio",
"input",
return INVOKERESULT_NO_ERROR;
case ID_root_VersionInfo:
{
- int len = strlen(libvlc_get_version());
+ const char *s = libvlc_get_version();
+ int len = strlen(s);
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
- if( retval )
- {
- memcpy(retval, libvlc_get_version(), len);
- STRINGN_TO_NPVARIANT(retval, len, result);
- }
- else
- {
- NULL_TO_NPVARIANT(result);
- }
+ if( !retval )
+ return INVOKERESULT_OUT_OF_MEMORY;
+
+ memcpy(retval, s, len);
+ STRINGN_TO_NPVARIANT(retval, len, result);
return INVOKERESULT_NO_ERROR;
}
default:
case ID_root_versionInfo:
if( argCount == 0 )
{
- int len = strlen(libvlc_get_version());
+ const char *s = libvlc_get_version();
+ int len = strlen(s);
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
- if( retval )
- {
- memcpy(retval, libvlc_get_version(), len);
- STRINGN_TO_NPVARIANT(retval, len, result);
- }
- else
- {
- NULL_TO_NPVARIANT(result);
- }
+ if( !retval )
+ return INVOKERESULT_OUT_OF_MEMORY;
+ memcpy(retval, s, len);
+ STRINGN_TO_NPVARIANT(retval, len, result);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
** implementation of libvlc audio object
*/
-const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
{
"mute",
"volume",
}
case ID_audio_track:
{
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
int track = libvlc_audio_get_track(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(track, result);
return INVOKERESULT_NO_ERROR;
case ID_audio_track:
if( isNumberValue(value) )
{
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_set_track(p_md, numberValue(value), &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
** implementation of libvlc input object
*/
-const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
{
"length",
"position",
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
if( libvlc_exception_raised(&ex) )
{
if( index != ID_input_state )
case ID_input_length:
{
double val = (double)libvlc_media_player_get_length(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_input_position:
{
double val = libvlc_media_player_get_position(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_input_time:
{
double val = (double)libvlc_media_player_get_time(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_input_state:
{
int val = libvlc_media_player_get_state(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_input_rate:
{
float val = libvlc_media_player_get_rate(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_input_fps:
{
double val = libvlc_media_player_get_fps(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_input_hasvout:
{
- bool val = libvlc_media_player_has_vout(p_md, &ex);
- libvlc_media_player_release(p_md);
+ bool val = p_plugin->player_has_vout(&ex);
RETURN_ON_EXCEPTION(this,ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
default:
;
}
- libvlc_media_player_release(p_md);
}
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index )
{
if( ! NPVARIANT_IS_DOUBLE(value) )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
float val = (float)NPVARIANT_TO_DOUBLE(value);
libvlc_media_player_set_position(p_md, val, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
val = (int64_t)NPVARIANT_TO_DOUBLE(value);
else
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
libvlc_media_player_set_time(p_md, val, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
val = (float)NPVARIANT_TO_DOUBLE(value);
else
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
libvlc_media_player_set_rate(p_md, val, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
- libvlc_media_player_release(p_md);
}
return INVOKERESULT_GENERIC_ERROR;
}
** implementation of libvlc message object
*/
-const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
{
"severity",
"type",
libvlc_log_iterator_free(_p_iter, NULL);
}
-const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
{
"hasNext",
};
** implementation of libvlc message object
*/
-const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
{
"count",
};
}
};
-const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
{
"messages",
"verbosity",
** implementation of libvlc playlist items object
*/
-const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
{
"count",
};
{
case ID_playlistitems_count:
{
- libvlc_playlist_lock(p_plugin->getVLC());
- int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
- libvlc_playlist_unlock(p_plugin->getVLC());
+ int val = p_plugin->playlist_count(&ex);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_playlistitems_clear:
if( argCount == 0 )
{
- libvlc_playlist_clear(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_clear(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlistitems_remove:
if( (argCount == 1) && isNumberValue(args[0]) )
{
- libvlc_playlist_delete_item(p_plugin->getVLC(),
- numberValue(args[0]), &ex);
+ p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
};
-const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
{
"itemCount", /* deprecated */
"isPlaying",
{
case ID_playlist_itemcount: /* deprecated */
{
- libvlc_playlist_lock(p_plugin->getVLC());
- int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
- libvlc_playlist_unlock(p_plugin->getVLC());
+ int val = p_plugin->playlist_count(&ex);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_playlist_isplaying:
{
- libvlc_playlist_lock(p_plugin->getVLC());
- int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
- libvlc_playlist_unlock(p_plugin->getVLC());
+ int val = p_plugin->playlist_isplaying(&ex);
RETURN_ON_EXCEPTION(this,ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
switch( index )
{
+ // XXX FIXME this needs squashing into something much smaller
case ID_playlist_add:
{
if( (argCount < 1) || (argCount > 3) )
}
}
- int item = libvlc_playlist_add_extended_untrusted(
- p_plugin->getVLC(), url, name, i_options,
+ int item = p_plugin->playlist_add_extended_untrusted(url, name, i_options,
const_cast<const char **>(ppsz_options), &ex);
free(url);
free(name);
case ID_playlist_play:
if( argCount == 0 )
{
- libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
+ p_plugin->playlist_play(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_playItem:
if( (argCount == 1) && isNumberValue(args[0]) )
{
- libvlc_playlist_play(p_plugin->getVLC(),
- numberValue(args[0]), 0, NULL, &ex);
+ p_plugin->playlist_play_item(numberValue(args[0]),&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_togglepause:
if( argCount == 0 )
{
- libvlc_playlist_pause(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_pause(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_stop:
if( argCount == 0 )
{
- libvlc_playlist_stop(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_stop(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_next:
if( argCount == 0 )
{
- libvlc_playlist_next(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_next(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_prev:
if( argCount == 0 )
{
- libvlc_playlist_prev(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_prev(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_clear: /* deprecated */
if( argCount == 0 )
{
- libvlc_playlist_clear(p_plugin->getVLC(), &ex);
+ p_plugin->playlist_clear(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
case ID_playlist_removeitem: /* deprecated */
if( (argCount == 1) && isNumberValue(args[0]) )
{
- libvlc_playlist_delete_item(p_plugin->getVLC(),
- numberValue(args[0]), &ex);
+ p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
return INVOKERESULT_GENERIC_ERROR;
}
+// XXX FIXME The new playlist_add creates a media instance and feeds it
+// XXX FIXME these options one at a time, so this hunk of code does lots
+// XXX FIXME of unnecessairy work. Break out something that can do one
+// XXX FIXME option at a time and doesn't need to realloc().
+// XXX FIXME Same for the other version of parseOptions.
+
void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
int *i_options, char*** ppsz_options)
{
if( nOptions == capacity )
{
capacity += 16;
- char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
+ char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
if( ! moreOptions )
{
/* failed to allocate more memory */
}
}
+// XXX FIXME See comment at the other parseOptions variant.
void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
char*** ppsz_options)
{
if( nOptions == capacity )
{
capacity += 16;
- char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
+ char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
if( ! moreOptions )
{
/* failed to allocate more memory */
** implementation of libvlc video object
*/
-const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
{
"fullscreen",
"height",
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index )
{
case ID_video_fullscreen:
{
- int val = libvlc_get_fullscreen(p_md, &ex);
- libvlc_media_player_release(p_md);
+ int val = p_plugin->get_fullscreen(&ex);
RETURN_ON_EXCEPTION(this,ex);
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_video_height:
{
int val = libvlc_video_get_height(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_video_width:
{
int val = libvlc_video_get_width(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
case ID_video_aspectratio:
{
NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
if( !psz_aspect )
return INVOKERESULT_GENERIC_ERROR;
case ID_video_subtitle:
{
int i_spu = libvlc_video_get_spu(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(i_spu, result);
return INVOKERESULT_NO_ERROR;
case ID_video_crop:
{
NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
if( !psz_geometry )
return INVOKERESULT_GENERIC_ERROR;
case ID_video_teletext:
{
int i_page = libvlc_video_get_teletext(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(i_page, result);
return INVOKERESULT_NO_ERROR;
}
}
- libvlc_media_player_release(p_md);
}
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index )
{
if( ! NPVARIANT_IS_BOOLEAN(value) )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
int val = NPVARIANT_TO_BOOLEAN(value);
- libvlc_set_fullscreen(p_md, val, &ex);
- libvlc_media_player_release(p_md);
-
+ p_plugin->set_fullscreen(val, &ex);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
if( ! NPVARIANT_IS_STRING(value) )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
if( !psz_aspect )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
free(psz_aspect);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
{
if( isNumberValue(value) )
{
- libvlc_video_set_spu(p_md,
- numberValue(value), &ex);
- libvlc_media_player_release(p_md);
+ libvlc_video_set_spu(p_md, numberValue(value), &ex);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
case ID_video_crop:
if( ! NPVARIANT_IS_STRING(value) )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
if( !psz_geometry )
{
- libvlc_media_player_release(p_md);
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
free(psz_geometry);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
{
if( isNumberValue(value) )
{
- libvlc_video_set_teletext(p_md,
- numberValue(value), &ex);
- libvlc_media_player_release(p_md);
+ libvlc_video_set_teletext(p_md, numberValue(value), &ex);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR;
}
- libvlc_media_player_release(p_md);
return INVOKERESULT_INVALID_VALUE;
}
}
- libvlc_media_player_release(p_md);
}
return INVOKERESULT_GENERIC_ERROR;
}
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index )
case ID_video_togglefullscreen:
if( argCount == 0 )
{
- libvlc_toggle_fullscreen(p_md, &ex);
- libvlc_media_player_release(p_md);
+ p_plugin->toggle_fullscreen(&ex);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
if( argCount == 0 )
{
libvlc_toggle_teletext(p_md, &ex);
- libvlc_media_player_release(p_md);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
b_autoplay(1),
b_toolbar(0),
psz_target(NULL),
+ playlist_index(-1),
libvlc_instance(NULL),
+ libvlc_media_list(NULL),
+ libvlc_media_player(NULL),
libvlc_log(NULL),
p_scriptClass(NULL),
p_browser(instance),
libvlc_exception_init(&ex);
libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
+
+ if( libvlc_exception_raised(&ex) )
+ {
+ libvlc_exception_clear(&ex);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
if( libvlc_exception_raised(&ex) )
{
libvlc_exception_clear(&ex);
return NPERR_GENERIC_ERROR;
}
- libvlc_exception_clear(&ex);
/*
** fetch plugin base URL, which is the URL of the page containing the plugin
free(psz_target);
if( libvlc_log )
libvlc_log_close(libvlc_log, NULL);
+ if( libvlc_media_player )
+ libvlc_media_player_release( libvlc_media_player );
+ if( libvlc_media_list )
+ libvlc_media_list_release( libvlc_media_list );
if( libvlc_instance )
libvlc_release(libvlc_instance);
}
+/*****************************************************************************
+ * VlcPlugin playlist replacement methods
+ *****************************************************************************/
+void VlcPlugin::set_player_window( libvlc_exception_t *ex )
+{
+#ifdef XP_UNIX
+ libvlc_media_player_set_xwindow(libvlc_media_player,
+ (libvlc_drawable_t)getWindow().window,
+ ex);
+#endif
+#ifdef XP_MACOSX
+ // XXX FIXME insert appropriate call here
+#endif
+#ifdef XP_WIN
+ libvlc_media_player_set_hwnd(libvlc_media_player,
+ getWindow().window,
+ ex);
+#endif
+}
+
+int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
+{
+ int item = -1;
+ libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl,ex);
+ if( libvlc_exception_raised(ex) )
+ return -1;
+
+ libvlc_media_list_lock(libvlc_media_list);
+ libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
+ if( !libvlc_exception_raised(ex) )
+ item = libvlc_media_list_count(libvlc_media_list,ex)-1;
+ libvlc_media_list_unlock(libvlc_media_list);
+
+ libvlc_media_release(p_m);
+
+ return item;
+}
+
+int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
+ int optc, const char **optv, libvlc_exception_t *ex )
+{
+ libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
+ int item = -1;
+ if( libvlc_exception_raised(ex) )
+ return -1;
+
+ for( int i = 0; i < optc; ++i )
+ {
+ libvlc_media_add_option_untrusted(p_m, optv[i],ex);
+ if( libvlc_exception_raised(ex) )
+ {
+ libvlc_media_release(p_m);
+ return -1;
+ }
+ }
+
+ libvlc_media_list_lock(libvlc_media_list);
+ libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
+ if( !libvlc_exception_raised(ex) )
+ item = libvlc_media_list_count(libvlc_media_list,ex)-1;
+ libvlc_media_list_unlock(libvlc_media_list);
+ libvlc_media_release(p_m);
+
+ return item;
+}
+
+void VlcPlugin::playlist_play( libvlc_exception_t *ex )
+{
+ if( libvlc_media_player||playlist_select(0,ex) )
+ libvlc_media_player_play(libvlc_media_player,ex);
+}
+
+void VlcPlugin::playlist_play_item( int idx, libvlc_exception_t *ex )
+{
+ if( playlist_select(idx,ex) )
+ libvlc_media_player_play(libvlc_media_player,ex);
+}
+
+void VlcPlugin::playlist_stop( libvlc_exception_t *ex )
+{
+ if( libvlc_media_player )
+ libvlc_media_player_stop(libvlc_media_player,ex);
+}
+
+bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex )
+{
+ libvlc_media_t *p_m = NULL;
+
+ libvlc_media_list_lock(libvlc_media_list);
+
+ int count = libvlc_media_list_count(libvlc_media_list,ex);
+ if( libvlc_exception_raised(ex) )
+ goto bad_unlock;
+
+ if( idx<0||idx>=count )
+ goto bad_unlock;
+
+ playlist_index = idx;
+
+ p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex);
+ libvlc_media_list_unlock(libvlc_media_list);
+
+ if( libvlc_exception_raised(ex) )
+ return false;
+
+ if( libvlc_media_player )
+ {
+ libvlc_media_player_release( libvlc_media_player );
+ libvlc_media_player = NULL;
+ }
+
+ libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex);
+ if( libvlc_media_player )
+ set_player_window(ex);
+
+ libvlc_media_release( p_m );
+ return !libvlc_exception_raised(ex);
+
+bad_unlock:
+ libvlc_media_list_unlock(libvlc_media_list);
+ return false;
+}
+
+void VlcPlugin::playlist_next( libvlc_exception_t *ex )
+{
+ if( playlist_select(playlist_index+1,ex) )
+ libvlc_media_player_play(libvlc_media_player,ex);
+}
+
+void VlcPlugin::playlist_prev( libvlc_exception_t *ex )
+{
+ if( playlist_select(playlist_index-1,ex) )
+ libvlc_media_player_play(libvlc_media_player,ex);
+}
+
+void VlcPlugin::playlist_pause( libvlc_exception_t *ex )
+{
+ if( libvlc_media_player )
+ libvlc_media_player_pause(libvlc_media_player,ex);
+}
+
+void VlcPlugin::playlist_delete_item( int idx, libvlc_exception_t *ex )
+{
+ libvlc_media_list_lock(libvlc_media_list);
+ libvlc_media_list_remove_index(libvlc_media_list,idx,ex);
+ libvlc_media_list_unlock(libvlc_media_list);
+}
+
+void VlcPlugin::playlist_clear( libvlc_exception_t *ex )
+{
+ if( libvlc_media_list )
+ libvlc_media_list_release(libvlc_media_list);
+ libvlc_media_list = libvlc_media_list_new(getVLC(),ex);
+}
+
+int VlcPlugin::playlist_count( libvlc_exception_t *ex )
+{
+ int items_count = 0;
+ libvlc_media_list_lock(libvlc_media_list);
+ items_count = libvlc_media_list_count(libvlc_media_list,ex);
+ libvlc_media_list_unlock(libvlc_media_list);
+ return items_count;
+}
+
+int VlcPlugin::playlist_isplaying( libvlc_exception_t *ex )
+{
+ int is_playing = 0;
+ if( libvlc_media_player )
+ libvlc_media_player_is_playing( libvlc_media_player, ex );
+ return is_playing;
+}
+
+void VlcPlugin::toggle_fullscreen( libvlc_exception_t *ex )
+{
+ if( playlist_isplaying(ex) )
+ libvlc_toggle_fullscreen(libvlc_media_player,ex);
+}
+
+void VlcPlugin::set_fullscreen( int yes, libvlc_exception_t *ex )
+{
+ if( playlist_isplaying(ex) )
+ libvlc_set_fullscreen(libvlc_media_player,yes,ex);
+}
+
+int VlcPlugin::get_fullscreen( libvlc_exception_t *ex )
+{
+ int r = 0;
+ if( playlist_isplaying(ex) )
+ r = libvlc_get_fullscreen(libvlc_media_player,ex);
+ return r;
+}
+
+int VlcPlugin::player_has_vout( libvlc_exception_t *ex )
+{
+ int r = 0;
+ if( playlist_isplaying(ex) )
+ r = libvlc_media_player_has_vout(libvlc_media_player, ex);
+ return r;
+}
+
+
/*****************************************************************************
* VlcPlugin methods
*****************************************************************************/
void VlcPlugin::redrawToolbar()
{
- libvlc_media_player_t *p_md = NULL;
libvlc_exception_t ex;
- float f_position = 0.0;
int is_playing = 0;
bool b_mute = false;
unsigned int dst_x, dst_y;
getToolbarSize( &i_tb_width, &i_tb_height );
- /* get media instance */
libvlc_exception_init( &ex );
- p_md = libvlc_playlist_get_media_player( getVLC(), &ex );
- libvlc_exception_clear( &ex );
- if( p_md )
- {
- /* get isplaying */
- libvlc_playlist_lock( getVLC() );
- is_playing = libvlc_playlist_isplaying( getVLC(), &ex );
- libvlc_playlist_unlock( getVLC() );
- libvlc_exception_clear( &ex );
-
- /* get movie position in % */
- if( is_playing == 1 )
- {
- f_position = libvlc_media_player_get_position( p_md, &ex ) * 100.0;
- libvlc_exception_clear( &ex );
- }
- libvlc_media_player_release( p_md );
- }
/* get mute info */
b_mute = libvlc_audio_get_mute( getVLC(), &ex );
dst_y - (p_timeline->height >> 1),
(window.width-(dst_x+BTN_SPACE)), p_timeline->height );
- if( f_position > 0 )
- i_last_position = (int)( f_position *
- ( ((float)(window.width-(dst_x+BTN_SPACE))) / 100.0 ));
+
+
+ /* get movie position in % */
+ if( playlist_isplaying(&ex) )
+ {
+ i_last_position = (int)((window.width-(dst_x+BTN_SPACE))*
+ libvlc_media_player_get_position(libvlc_media_player,&ex));
+ }
+ libvlc_exception_clear( &ex );
if( p_btnTime )
XPutImage( p_display, control, gc, p_btnTime,
/* get isplaying */
libvlc_exception_init( &ex );
- libvlc_playlist_lock( getVLC() );
- is_playing = libvlc_playlist_isplaying( getVLC(), &ex );
- libvlc_playlist_unlock( getVLC() );
+ is_playing = playlist_isplaying( &ex );
libvlc_exception_clear( &ex );
/* get mute info */
int16 NPP_HandleEvent( NPP instance, void * event )
{
static UInt32 lastMouseUp = 0;
+ libvlc_exception_t ex;
+ libvlc_exception_init(&ex);
if( instance == NULL )
{
if( (myEvent->when - lastMouseUp) < GetDblTime() )
{
/* double click */
- libvlc_instance_t *p_vlc = p_plugin->getVLC();
- if( p_vlc )
- {
- int is_playing;
- libvlc_playlist_lock(p_vlc);
- is_playing = libvlc_playlist_isplaying(p_vlc, NULL);
- libvlc_playlist_unlock(p_vlc);
- if( is_playing )
- {
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_vlc, NULL);
- if( p_md )
- {
- libvlc_toggle_fullscreen(p_md, NULL);
- libvlc_media_player_release(p_md);
- }
- }
- }
+ p_plugin->toggle_fullscreen(&ex);
+ libvlc_exception_clear(&ex);
}
return true;
}
if( npwindow.window )
{
int hasVout = FALSE;
- libvlc_instance_t *p_vlc = p_plugin->getVLC();
- if( p_vlc )
+ if( p_plugin->playlist_isplaying(&ex) )
{
- int is_playing;
- libvlc_playlist_lock(p_vlc);
- is_playing = libvlc_playlist_isplaying(p_vlc, NULL);
- libvlc_playlist_unlock(p_vlc);
- if( is_playing )
+ hasVout = p_plugin->player_has_vout(NULL);
+ if( hasVout )
{
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_vlc, NULL);
- if( p_md )
- {
- hasVout = libvlc_media_player_has_vout(p_md,
- NULL);
- if( hasVout )
- {
- libvlc_rectangle_t area;
- area.left = 0;
- area.top = 0;
- area.right = npwindow.width;
- area.bottom = npwindow.height;
- libvlc_video_redraw_rectangle(p_md, &area,
- NULL);
- }
- libvlc_media_player_release(p_md);
- }
+ libvlc_rectangle_t area;
+ area.left = 0;
+ area.top = 0;
+ area.right = npwindow.width;
+ area.bottom = npwindow.height;
+ libvlc_video_redraw_rectangle(p_md, &area, NULL);
}
}
+ libvlc_exception_clear(&ex);
if( ! hasVout )
{
libvlc_exception_t ex;
libvlc_exception_init(& ex );
- p_md = libvlc_playlist_get_media_player( p_plugin->getVLC(), &ex );
- libvlc_exception_init( &ex );
+ p_md = p_plugin->getMD( &ex );
+ libvlc_exception_clear( &ex );
libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),
libvlc_MediaPlayerPositionChanged, Redraw, NULL, &ex );
*/
{
if( p_plugin->psz_target )
{
- if( libvlc_playlist_add( p_vlc, p_plugin->psz_target,
- NULL, NULL ) != -1 )
+ if( p_plugin->playlist_add( p_plugin->psz_target, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
- libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
+ p_plugin->playlist_play(NULL);
}
}
p_plugin->b_stream = true;
return;
}
- if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL )
- != -1 )
+ if( p_plugin->playlist_add( stream->url, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
- libvlc_playlist_play( p_plugin->getVLC(), 0, 0, NULL, NULL);
+ p_plugin->playlist_play(NULL);
}
}
}
libvlc_exception_t ex;
libvlc_exception_init( &ex );
- libvlc_media_player_t *p_md =
- libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
if( libvlc_exception_raised(&ex) )
fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
libvlc_exception_clear( &ex );
- libvlc_playlist_lock( p_plugin->getVLC() );
- i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
- libvlc_playlist_unlock( p_plugin->getVLC() );
+ i_playing = p_plugin->playlist_isplaying( &ex );
if( libvlc_exception_raised(&ex) )
fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
libvlc_exception_clear( &ex );
case clicked_Pause:
{
if( i_playing == 1 )
- libvlc_playlist_pause( p_plugin->getVLC(), &ex );
+ p_plugin->playlist_pause( &ex );
else
- libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
+ p_plugin->playlist_play( &ex );
if( libvlc_exception_raised(&ex) )
fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
case clicked_Stop:
{
- libvlc_playlist_stop( p_plugin->getVLC(), &ex );
+ p_plugin->playlist_stop(&ex);
if( libvlc_exception_raised(&ex) )
fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
libvlc_exception_clear( &ex );
case clicked_Fullscreen:
{
- if( (i_playing == 1) && p_md )
- {
- libvlc_set_fullscreen( p_md, 1, &ex );
- if( libvlc_exception_raised(&ex) )
- fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
- libvlc_exception_clear( &ex );
- }
+ p_plugin->set_fullscreen( 1, &ex );
+ if( libvlc_exception_raised(&ex) )
+ fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+ libvlc_exception_clear( &ex );
}
break;
default: /* button_Unknown */
break;
}
- if( p_md ) libvlc_media_player_release( p_md );
}
Redraw( w, closure, event );
}