📄 npovlc.cpp
字号:
return INVOKERESULT_INVALID_ARGS;
}
}
else
return INVOKERESULT_OUT_OF_MEMORY;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_str_variable: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s )
{
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val;
if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
{
delete s;
if( val.psz_string )
{
int len = strlen(val.psz_string);
NPUTF8 *retval = (NPUTF8 *)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, val.psz_string, len);
STRINGN_TO_NPVARIANT(retval, len, result);
free(val.psz_string);
return INVOKERESULT_NO_ERROR;
}
else
{
return INVOKERESULT_OUT_OF_MEMORY;
}
}
else
{
/* null string */
NULL_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
}
else
{
delete s;
return INVOKERESULT_INVALID_ARGS;
}
}
else
return INVOKERESULT_OUT_OF_MEMORY;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_set_str_variable: /* deprecated */
if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0])
&& NPVARIANT_IS_STRING(args[1]) )
{
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s )
{
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val;
val.psz_string = stringValue(NPVARIANT_TO_STRING(args[1]));
if( val.psz_string )
{
if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
{
delete s;
delete val.psz_string;
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
else
{
delete s;
delete val.psz_string;
return INVOKERESULT_INVALID_ARGS;
}
}
else
{
delete s;
return INVOKERESULT_OUT_OF_MEMORY;
}
}
else
return INVOKERESULT_OUT_OF_MEMORY;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_clear_playlist: /* 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 INVOKERESULT_NO_SUCH_METHOD;
case ID_add_item: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s )
{
char *url = p_plugin->getAbsoluteURL(s);
delete s;
if( ! url )
// what happened ?
return INVOKERESULT_GENERIC_ERROR;
int item = libvlc_playlist_add(p_plugin->getVLC(), url, NULL, &ex);
free(url);
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;
}
}
else
return INVOKERESULT_OUT_OF_MEMORY;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_next: /* deprecated */
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 INVOKERESULT_NO_SUCH_METHOD;
case ID_previous: /* deprecated */
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 INVOKERESULT_NO_SUCH_METHOD;
case ID_isplaying: /* deprecated */
if( argCount == 0 )
{
int isplaying = libvlc_playlist_isplaying(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
{
BOOLEAN_TO_NPVARIANT(isplaying, result);
return INVOKERESULT_NO_ERROR;
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_length: /* deprecated */
if( argCount == 0 )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( p_input )
{
vlc_int64_t val = libvlc_input_get_length(p_input, &ex);
libvlc_input_free(p_input);
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((uint32_t)(val/1000LL), result);
return INVOKERESULT_NO_ERROR;
}
}
else
{
/* cannot get input, 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 INVOKERESULT_NO_SUCH_METHOD;
case ID_get_position: /* deprecated */
if( argCount == 0 )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( p_input )
{
float val = libvlc_input_get_position(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
DOUBLE_TO_NPVARIANT((double)val, result);
return INVOKERESULT_NO_ERROR;
}
}
else
{
/* cannot get input, 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 INVOKERESULT_NO_SUCH_METHOD;
case ID_get_time: /* deprecated */
if( argCount == 0 )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( p_input )
{
vlc_int64_t val = libvlc_input_get_time(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
DOUBLE_TO_NPVARIANT((uint32_t)(val/1000LL), result);
return INVOKERESULT_NO_ERROR;
}
}
else
{
/* cannot get input, 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 INVOKERESULT_NO_SUCH_METHOD;
case ID_seek: /* deprecated */
if( (argCount == 2)
&& isNumberValue(args[0])
&& NPVARIANT_IS_BOOLEAN(args[1]) )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( p_input )
{
vlc_int64_t pos = 0;
if( NPVARIANT_IS_INT32(args[0]) )
pos = (vlc_int64_t)NPVARIANT_TO_INT32(args[0]);
else
pos = (vlc_int64_t)NPVARIANT_TO_DOUBLE(args[0]);
if( NPVARIANT_TO_BOOLEAN(args[1]) )
{
/* relative seek */
vlc_int64_t from = libvlc_input_get_time(p_input, &ex);
if( libvlc_exception_raised(&ex) )
{
libvlc_input_free(p_input);
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
pos += from;
}
/* jump to time */
libvlc_input_set_time(p_input, pos, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
else
{
/* cannot get input, 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 INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -