/*****************************************************************************\r
- * vlc.cpp: support for NPRuntime API for Netscape Script-able plugins\r
- * FYI: http://www.mozilla.org/projects/plugins/npruntime.html\r
+ * npolibvlc.cpp: official Javascript APIs\r
*****************************************************************************\r
- * Copyright (C) 2005 the VideoLAN team\r
+ * Copyright (C) 2002-2006 the VideoLAN team\r
*\r
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
*\r
LibvlcRootNPObject::LibvlcRootNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass)\r
{\r
- static NPClass *audioClass = new RuntimeNPClass<LibvlcAudioNPObject>();\r
- static NPClass *inputClass = new RuntimeNPClass<LibvlcInputNPObject>();\r
- static NPClass *playlistClass = new RuntimeNPClass<LibvlcPlaylistNPObject>();\r
- static NPClass *videoClass = new RuntimeNPClass<LibvlcVideoNPObject>();\r
-\r
- audioObj = NPN_CreateObject(instance, audioClass);\r
- inputObj = NPN_CreateObject(instance, inputClass);\r
- playlistObj = NPN_CreateObject(instance, playlistClass);\r
- videoObj = NPN_CreateObject(instance, videoClass);\r
+ audioObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcAudioNPObject>::getClass());\r
+ inputObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcInputNPObject>::getClass());\r
+ playlistObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());\r
+ videoObj = NPN_CreateObject(instance,RuntimeNPClass<LibvlcVideoNPObject>::getClass());\r
}\r
\r
LibvlcRootNPObject::~LibvlcRootNPObject()\r
"video",\r
};\r
\r
+const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propertyNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcRootNPObjectPropertyIds\r
{\r
ID_audio = 0,\r
ID_video,\r
};\r
\r
-const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propertyNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)\r
{\r
switch( index )\r
"volume",\r
};\r
\r
+const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::propertyNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcAudioNPObjectPropertyIds\r
{\r
ID_mute,\r
ID_volume,\r
};\r
\r
-const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::propertyNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)\r
{\r
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
"togglemute",\r
};\r
\r
+const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcAudioNPObjectMethodIds\r
{\r
ID_togglemute,\r
};\r
\r
-const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)\r
{\r
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
"hasvout",\r
};\r
\r
+const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::propertyNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcInputNPObjectPropertyIds\r
{\r
ID_length,\r
ID_hasvout,\r
};\r
\r
-const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::propertyNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)\r
{\r
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
"isplaying",\r
};\r
\r
+const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcPlaylistNPObjectPropertyIds\r
{\r
ID_itemscount,\r
ID_isplaying,\r
};\r
\r
-const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)\r
{\r
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
"deleteitem"\r
};\r
\r
+const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);\r
+\r
enum LibvlcPlaylistNPObjectMethodIds\r
{\r
ID_add,\r
ID_deleteitem,\r
};\r
\r
-const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);\r
-\r
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)\r
{\r
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
{\r
case ID_add:\r
{\r
- char *url = NULL;\r
- char *name = NULL;\r
- int i_options = 0;\r
- char** ppsz_options = NULL;\r
-\r
if( (argCount < 1) || (argCount > 3) )\r
return INVOKERESULT_NO_SUCH_METHOD;\r
\r
+ char *url = NULL;\r
+\r
// grab URL\r
if( NPVARIANT_IS_STRING(args[0]) )\r
{\r
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));\r
if( s )\r
{\r
- char *url = p_plugin->getAbsoluteURL(s);\r
+ url = p_plugin->getAbsoluteURL(s);\r
delete s;\r
if( ! url )\r
// what happened ?\r
else\r
return INVOKERESULT_NO_SUCH_METHOD;\r
\r
+ char *name = NULL;\r
+\r
// grab name if available\r
if( argCount > 1 )\r
{\r
return INVOKERESULT_NO_SUCH_METHOD;\r
}\r
\r
+ int i_options = 0;\r
+ char** ppsz_options = NULL;\r
+\r
// grab options if available\r
if( argCount > 2 )\r
{\r
}\r
else if( NPVARIANT_IS_STRING(args[2]) )\r
{\r
- parseOptions(NPVARIANT_TO_STRING(args[0]), &i_options, &ppsz_options);\r
+ parseOptions(NPVARIANT_TO_STRING(args[2]), &i_options, &ppsz_options);\r
\r
}\r
- else if( NPVARIANT_IS_OBJECT(args[3]) )\r
+ else if( NPVARIANT_IS_OBJECT(args[2]) )\r
{\r
- parseOptions(NPVARIANT_TO_OBJECT(args[0]), &i_options, &ppsz_options);\r
+ parseOptions(NPVARIANT_TO_OBJECT(args[2]), &i_options, &ppsz_options);\r
}\r
}\r
\r
delete name;\r
for( int i=0; i< i_options; ++i )\r
{\r
- delete ppsz_options[i];\r
+ if( ppsz_options[i] )\r
+ free(ppsz_options[i]);\r
}\r
- delete ppsz_options;\r
+ if( ppsz_options )\r
+ free(ppsz_options);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
{\r
// skip leading blanks\r
while( (val < end)\r
- && ((*val == ' ' ) || (*val != '\t')) )\r
+ && ((*val == ' ' ) || (*val == '\t')) )\r
++val;\r
\r
char *start = val;\r
\r
void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options, char*** ppsz_options)\r
{\r
- NPIdentifier name = NPN_GetStringIdentifier("length");\r
/* we are expecting to have a Javascript Array object */\r
+ NPIdentifier name = NPN_GetStringIdentifier("length");\r
if( NPN_HasProperty(_instance, obj, name) )\r
{\r
NPVariant value;\r
{\r
int count = numberValue(value);\r
NPN_ReleaseVariantValue(&value);\r
+\r
if( count )\r
{\r
long capacity = 16;\r
/*****************************************************************************\r
- * vlc.h: a VLC plugin for Mozilla\r
+ * npolibvlc.h: official Javascript APIs\r
*****************************************************************************\r
- * Copyright (C) 2002-2005 the VideoLAN team\r
- * $Id: vlcruntime.h 14466 2006-02-22 23:34:54Z dionoea $\r
+ * Copyright (C) 2002-2006 the VideoLAN team\r
*\r
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net>\r
*\r
\r
class LibvlcRootNPObject: public RuntimeNPObject\r
{\r
-public:\r
- LibvlcRootNPObject(NPP instance, const NPClass *aClass);\r
- virtual ~LibvlcRootNPObject();\r
-\r
protected:\r
friend class RuntimeNPClass<LibvlcRootNPObject>;\r
\r
+ LibvlcRootNPObject(NPP instance, const NPClass *aClass);\r
+ virtual ~LibvlcRootNPObject();\r
+\r
static const int propertyCount;\r
static const NPUTF8 * const propertyNames[];\r
\r
\r
class LibvlcAudioNPObject: public RuntimeNPObject\r
{\r
-public:\r
+protected:\r
LibvlcAudioNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
virtual ~LibvlcAudioNPObject() {};\r
\r
-protected:\r
friend class RuntimeNPClass<LibvlcAudioNPObject>;\r
\r
static const int propertyCount;\r
\r
class LibvlcInputNPObject: public RuntimeNPObject\r
{\r
-public:\r
+protected:\r
+ friend class RuntimeNPClass<LibvlcInputNPObject>;\r
+\r
LibvlcInputNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
\r
virtual ~LibvlcInputNPObject() {};\r
\r
-protected:\r
- friend class RuntimeNPClass<LibvlcInputNPObject>;\r
-\r
static const int propertyCount;\r
static const NPUTF8 * const propertyNames[];\r
\r
\r
class LibvlcPlaylistNPObject: public RuntimeNPObject\r
{\r
-public:\r
+protected:\r
+ friend class RuntimeNPClass<LibvlcPlaylistNPObject>;\r
+\r
LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
virtual ~LibvlcPlaylistNPObject() {};\r
\r
-protected:\r
- friend class RuntimeNPClass<LibvlcPlaylistNPObject>;\r
-\r
static const int propertyCount;\r
static const NPUTF8 * const propertyNames[];\r
\r
\r
class LibvlcVideoNPObject: public RuntimeNPObject\r
{\r
-public:\r
+protected:\r
+ friend class RuntimeNPClass<LibvlcVideoNPObject>;\r
+\r
LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
virtual ~LibvlcVideoNPObject() {};\r
\r
-protected:\r
- friend class RuntimeNPClass<LibvlcVideoNPObject>;\r
-\r
static const int propertyCount;\r
static const NPUTF8 * const propertyNames[];\r
\r
static const NPUTF8 * const methodNames[];\r
\r
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
-\r
};\r
\r
/*****************************************************************************
- * runtime.h: a VLC plugin for Mozilla
+ * runtime.cpp: support for NPRuntime API for Netscape Script-able plugins
+ * FYI: http://www.mozilla.org/projects/plugins/npruntime.html
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* $Id: RuntimeNPObject.h 14466 2006-02-22 23:34:54Z dionoea $
#include <npapi.h>
#include <npruntime.h>
+static void RuntimeNPClassDeallocate(NPObject *npobj);
+static void RuntimeNPClassInvalidate(NPObject *npobj);
+static bool RuntimeNPClassInvokeDefault(NPObject *npobj,
+ const NPVariant *args,
+ uint32_t argCount,
+ NPVariant *result);
+
class RuntimeNPObject : public NPObject
{
public:
+
+ /*
+ ** utility functions
+ */
+
static bool isNumberValue(const NPVariant &v)
{
return NPVARIANT_IS_INT32(v)
static char* stringValue(const NPString &v);
static char* stringValue(const NPVariant &v);
+protected:
+
RuntimeNPObject(NPP instance, const NPClass *aClass) :
_instance(instance)
{
};
virtual ~RuntimeNPObject() {};
- /*
- ** utility functions
- */
-
-protected:
-
enum InvokeResult
{
INVOKERESULT_NO_ERROR = 0, /* returns no error */
INVOKERESULT_OUT_OF_MEMORY = 5, /* throws out of memory */
};
- template <class RuntimeNPObject> friend void RuntimeNPClassInvalidate(NPObject *npobj);
+ friend void RuntimeNPClassDeallocate(NPObject *npobj);
+ friend void RuntimeNPClassInvalidate(NPObject *npobj);
template <class RuntimeNPObject> friend bool RuntimeNPClassGetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result);
template <class RuntimeNPObject> friend bool RuntimeNPClassSetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value);
template <class RuntimeNPObject> friend bool RuntimeNPClassRemoveProperty(NPObject *npobj, NPIdentifier name);
template <class RuntimeNPObject> friend bool RuntimeNPClassInvoke(NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
- template <class RuntimeNPObject> friend bool RuntimeNPClassInvokeDefault(NPObject *npobj,
- const NPVariant *args,
- uint32_t argCount,
- NPVariant *result);
+ friend bool RuntimeNPClassInvokeDefault(NPObject *npobj,
+ const NPVariant *args,
+ uint32_t argCount,
+ NPVariant *result);
virtual InvokeResult getProperty(int index, NPVariant &result);
virtual InvokeResult setProperty(int index, const NPVariant &value);
template<class T> class RuntimeNPClass : public NPClass
{
public:
+ static NPClass *getClass()
+ {
+ static NPClass *singleton = new RuntimeNPClass<T>;
+ return singleton;
+ }
+
+protected:
RuntimeNPClass();
virtual ~RuntimeNPClass();
- /*template <class T> friend NPObject *RuntimeNPClassAllocate(NPP instance, NPClass *aClass);
+ template <class RuntimeNPObject> friend NPObject *RuntimeNPClassAllocate(NPP instance, NPClass *aClass);
template <class RuntimeNPObject> friend bool RuntimeNPClassHasMethod(NPObject *npobj, NPIdentifier name);
- template <class RuntimeNPObject> friend bool RuntimeNPClassHasProperty(NPObject *npobj, NPIdentifier name);*/
+ template <class RuntimeNPObject> friend bool RuntimeNPClassHasProperty(NPObject *npobj, NPIdentifier name);
+ template <class RuntimeNPObject> friend bool RuntimeNPClassGetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result);
+ template <class RuntimeNPObject> friend bool RuntimeNPClassSetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value);
+ template <class RuntimeNPObject> friend bool RuntimeNPClassRemoveProperty(NPObject *npobj, NPIdentifier name);
+ template <class RuntimeNPObject> friend bool RuntimeNPClassInvoke(NPObject *npobj, NPIdentifier name,
+ const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
RuntimeNPObject *create(NPP instance) const;
return (NPObject *)vClass->create(instance);
}
-template<class T>
static void RuntimeNPClassDeallocate(NPObject *npobj)
{
RuntimeNPObject *vObj = static_cast<RuntimeNPObject *>(npobj);
delete vObj;
}
-template<class T>
static void RuntimeNPClassInvalidate(NPObject *npobj)
{
RuntimeNPObject *vObj = static_cast<RuntimeNPObject *>(npobj);
return false;
}
-template<class T>
static bool RuntimeNPClassInvokeDefault(NPObject *npobj,
const NPVariant *args,
uint32_t argCount,
// fill in NPClass structure
structVersion = NP_CLASS_STRUCT_VERSION;
- allocate = RuntimeNPClassAllocate<T>;
- deallocate = RuntimeNPClassDeallocate<T>;
- invalidate = RuntimeNPClassInvalidate<T>;
- hasMethod = RuntimeNPClassHasMethod<T>;
- invoke = RuntimeNPClassInvoke<T>;
- invokeDefault = RuntimeNPClassInvokeDefault<T>;
- hasProperty = RuntimeNPClassHasProperty<T>;
- getProperty = RuntimeNPClassGetProperty<T>;
- setProperty = RuntimeNPClassSetProperty<T>;
- removeProperty = RuntimeNPClassRemoveProperty<T>;
+ allocate = &RuntimeNPClassAllocate<T>;
+ deallocate = &RuntimeNPClassDeallocate;
+ invalidate = &RuntimeNPClassInvalidate;
+ hasMethod = &RuntimeNPClassHasMethod<T>;
+ invoke = &RuntimeNPClassInvoke<T>;
+ invokeDefault = &RuntimeNPClassInvokeDefault;
+ hasProperty = &RuntimeNPClassHasProperty<T>;
+ getProperty = &RuntimeNPClassGetProperty<T>;
+ setProperty = &RuntimeNPClassSetProperty<T>;
+ removeProperty = &RuntimeNPClassRemoveProperty<T>;
}
template<class T>
/*****************************************************************************\r
- * vlc.cpp: support for NPRuntime API for Netscape Script-able plugins\r
- * FYI: http://www.mozilla.org/projects/plugins/npruntime.html\r
+ * npovlc.cpp: deprecated VLC apis implemented in late XPCOM interface\r
*****************************************************************************\r
- * Copyright (C) 2005 the VideoLAN team\r
+ * Copyright (C) 2002-2006 the VideoLAN team\r
*\r
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
*\r
\r
const NPUTF8 * const VlcNPObject::methodNames[] =\r
{\r
- "play",\r
- "pause",\r
- "stop",\r
- "fullscreen",\r
- "set_volume",\r
- "get_volume",\r
- "mute",\r
- "get_int_variable",\r
- "set_int_variable",\r
- "get_bool_variable",\r
- "set_bool_variable",\r
- "get_str_variable",\r
- "set_str_variable",\r
- "clear_playlist",\r
- "add_item",\r
- "next",\r
- "previous",\r
- "isplaying",\r
- "get_length",\r
- "get_position",\r
- "get_time",\r
- "seek",\r
+ "play", /* deprecated */\r
+ "pause", /* deprecated */\r
+ "stop", /* deprecated */\r
+ "fullscreen", /* deprecated */\r
+ "set_volume", /* deprecated */\r
+ "get_volume", /* deprecated */\r
+ "mute", /* deprecated */\r
+ "get_int_variable", /* deprecated */\r
+ "set_int_variable", /* deprecated */\r
+ "get_bool_variable", /* deprecated */\r
+ "set_bool_variable", /* deprecated */\r
+ "get_str_variable", /* deprecated */\r
+ "set_str_variable", /* deprecated */\r
+ "clear_playlist", /* deprecated */\r
+ "add_item", /* deprecated */\r
+ "next", /* deprecated */\r
+ "previous", /* deprecated */\r
+ "isplaying", /* deprecated */\r
+ "get_length", /* deprecated */\r
+ "get_position", /* deprecated */\r
+ "get_time", /* deprecated */\r
+ "seek", /* deprecated */\r
};\r
\r
enum VlcNPObjectMethodIds\r
\r
switch( index )\r
{\r
- case ID_play:\r
+ case ID_play: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_pause:\r
+ case ID_pause: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_pause(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_stop:\r
+ case ID_stop: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_stop(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_fullscreen:\r
+ case ID_fullscreen: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_set_volume:\r
+ case ID_set_volume: /* deprecated */\r
if( (argCount == 1) && isNumberValue(args[0]) )\r
{\r
libvlc_audio_set_volume(p_plugin->getVLC(), numberValue(args[0]), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_volume:\r
+ case ID_get_volume: /* deprecated */\r
if( argCount == 0 )\r
{\r
int val = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_mute:\r
+ case ID_mute: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_int_variable:\r
+ case ID_get_int_variable: /* deprecated */\r
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )\r
{\r
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_set_int_variable:\r
+ case ID_set_int_variable: /* deprecated */\r
if( (argCount == 2)\r
&& NPVARIANT_IS_STRING(args[0])\r
&& isNumberValue(args[1]) )\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_bool_variable:\r
+ case ID_get_bool_variable: /* deprecated */\r
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )\r
{\r
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_set_bool_variable:\r
+ case ID_set_bool_variable: /* deprecated */\r
if( (argCount == 2)\r
&& NPVARIANT_IS_STRING(args[0])\r
&& NPVARIANT_IS_BOOLEAN(args[1]) )\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_str_variable:\r
+ case ID_get_str_variable: /* deprecated */\r
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )\r
{\r
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));\r
else\r
{\r
/* null string */\r
- STRINGN_TO_NPVARIANT(NULL, 0, result);\r
+ NULL_TO_NPVARIANT(result);\r
return INVOKERESULT_NO_ERROR;\r
}\r
}\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_set_str_variable:\r
+ case ID_set_str_variable: /* deprecated */\r
if( (argCount == 2)\r
&& NPVARIANT_IS_STRING(args[0])\r
&& NPVARIANT_IS_STRING(args[1]) )\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_clear_playlist:\r
+ case ID_clear_playlist: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_clear(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_add_item:\r
+ case ID_add_item: /* deprecated */\r
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )\r
{\r
char *s = stringValue(NPVARIANT_TO_STRING(args[0]));\r
return INVOKERESULT_OUT_OF_MEMORY;\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_next:\r
+ case ID_next: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_next(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_previous:\r
+ case ID_previous: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_playlist_prev(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_isplaying:\r
+ case ID_isplaying: /* deprecated */\r
if( argCount == 0 )\r
{\r
int isplaying = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_length:\r
+ case ID_get_length: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_position:\r
+ case ID_get_position: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_get_time:\r
+ case ID_get_time: /* deprecated */\r
if( argCount == 0 )\r
{\r
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
}\r
}\r
return INVOKERESULT_NO_SUCH_METHOD;\r
- case ID_seek:\r
+ case ID_seek: /* deprecated */\r
if( (argCount == 2)\r
&& isNumberValue(args[0])\r
&& NPVARIANT_IS_BOOLEAN(args[1]) )\r
/*****************************************************************************\r
- * vlc.h: a VLC plugin for Mozilla\r
+ * npovlc.h: deprecated APIs implemented in late XPCOM interface\r
*****************************************************************************\r
- * Copyright (C) 2002-2005 the VideoLAN team\r
- * $Id: vlcruntime.h 14466 2006-02-22 23:34:54Z dionoea $\r
+ * Copyright (C) 2002-2006 the VideoLAN team\r
*\r
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net>\r
*\r
\r
class VlcNPObject: public RuntimeNPObject\r
{\r
-public:\r
+protected:\r
+ friend class RuntimeNPClass<VlcNPObject>;\r
+\r
VlcNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
virtual ~VlcNPObject() {};\r
\r
-protected:\r
- friend class RuntimeNPClass<VlcNPObject>;\r
-\r
static const int propertyCount;\r
static const NPUTF8 * const propertyNames[];\r
\r
--- /dev/null
+<HTML>
+<TITLE>VLC Mozilla plugin test page</TITLE>
+<BODY>
+<TABLE>
+<TR><TD colspan="2">
+MRL:
+<INPUT size="90" id="targetTextField" value="">
+<INPUT type=submit value="Go" onClick="doGo(document.getElementById('targetTextField').value);">
+</TD></TR>
+<TR><TD colspan="2">
+<EMBED type="application/x-vlc-plugin" pluginspage="http://www.videolan.org/" version="VideoLAN.VLCPlugin.2"
+ width="640"
+ height="480"
+ id="vlc">
+</EMBED>
+</TD></TR>
+</TD><TD width="15%">
+<DIV id="info" style="text-align:center">-:--:--/-:--:--</DIV>
+</TD></TR>
+<TR><TD colspan="2">
+<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause()'>
+<INPUT type=button value="Stop" onClick='document.vlc.playlist.stop();'>
+
+<INPUT type=button value=" << " onClick='document.vlc.playlist.playSlower();'>
+<INPUT type=button value=" >> " onClick='document.vlc.playlist.playFaster();'>
+
+<INPUT type=button value="Show" onClick='document.vlc.visible = true;'>
+<INPUT type=button value="Hide" onClick='document.vlc.visible = false;'>
+
+<INPUT type=button value="Version" onClick='alert(document.vlc.VersionInfo);'>
+<SPAN style="text-align:center">Volume:</SPAN>
+<INPUT type=button value=" - " onClick='updateVolume(-10)'>
+<SPAN id="volumeTextField" style="text-align: center">--</SPAN>
+<INPUT type=button value=" + " onClick='updateVolume(+10)'>
+<INPUT type=button value="Mute" onClick='document.vlc.audio.togglemute();'>
+</TD>
+</TR>
+</TABLE>
+<SCRIPT LANGUAGE="Javascript">
+<!--
+var timerId = 0;
+
+function updateVolume(deltaVol)
+{
+ var plugin = document.getElementById('vlc');
+ plugin.audio.volume += deltaVol;
+ volumeTextField.innerText = plugin.audio.volume+"%";
+};
+function formatTime(timeVal)
+{
+ var timeHour = timeVal;
+ var timeSec = timeHour % 60;
+ if( timeSec < 10 )
+ timeSec = '0'+timeSec;
+ timeHour = (timeHour - timeSec)/60;
+ var timeMin = timeHour % 60;
+ if( timeMin < 10 )
+ timeMin = '0'+timeMin;
+ timeHour = (timeHour - timeMin)/60;
+ if( timeHour > 0 )
+ return timeHour+":"+timeMin+":"+timeSec;
+ else
+ return timeMin+":"+timeSec;
+};
+function onPlay()
+{
+ document.getElementById("PlayOrPause").value = "Pause";
+};
+function onPause()
+{
+ document.getElementById("PlayOrPause").value = " Play ";
+};
+function onStop()
+{
+ info.innerText = "-:--:--/-:--:--";
+ document.getElementById("PlayOrPause").value = " Play ";
+};
+var liveFeedText = new Array("Live", "((Live))", "(( Live ))", "(( Live ))");
+var liveFeedRoll = 0;
+
+function doUpdate()
+{
+ if( vlc.playlist.isplaying )
+ {
+ if( vlc.input.length > 0 )
+ {
+ // seekable stream
+ info.innerText = formatTime(vlc.input.time/1000)+"/"+formatTime(vlc.input.length/1000);
+ document.getElementById("PlayOrPause").Enabled = true;
+ }
+ else {
+ liveFeedRoll = liveFeedRoll & 3;
+ info.innerText = liveFeedText[liveFeedRoll++];
+ }
+ timerId = setTimeout("doUpdate()", 1000);
+ }
+ else
+ {
+ onStop();
+ timerId = 0;
+ }
+};
+function doGo(targetURL)
+{
+ var options = new Array(":vout-filter=deinterlace", ":deinterlace-mode=linear");
+ document.vlc.playlist.add(targetURL, null, options);
+};
+function doPlayOrPause()
+{
+ if( document.vlc.playlist.isplaying )
+ {
+ document.vlc.playlist.pause();
+ }
+ else
+ {
+ document.vlc.playlist.play();
+ }
+};
+function vlcPlayEvent()
+{
+ if( ! timerId )
+ {
+ timerId = setTimeout("doUpdate()", 1000);
+ }
+ onPlay();
+};
+function vlcPauseEvent()
+{
+ if( timerId )
+ {
+ clearTimeout(timerId)
+ timerId = 0;
+ }
+ onPause();
+};
+function vlcStopEvent()
+{
+ if( timerId )
+ {
+ clearTimeout(timerId)
+ timerId = 0;
+ }
+ onStop();
+};
+//-->
+</SCRIPT>
+</BODY>
+</HTML>
RegCloseKey( h_key );
}
ppsz_argv[ppsz_argc++] = "--no-one-instance";
+#if 0
+ ppsz_argv[ppsz_argc++] = "--fast-mutex";
+ ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
+#endif
#endif /* XP_MACOSX */
}
}
else if( !strcmp( argn[i], "version") )
- {
- version = argv[i];
- }
+ {
+ version = argv[i];
+ }
}
libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, NULL);
/* assign plugin script root class */
if( (NULL != version) && (!strcmp(version, "VideoLAN.VLCPlugin.2")) )
{
- /* new APIs */
- scriptClass = new RuntimeNPClass<LibvlcRootNPObject>();
+ /* new APIs */
+ scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
}
else
{
- /* legacy APIs */
- scriptClass = new RuntimeNPClass<VlcNPObject>();
+ /* legacy APIs */
+ scriptClass = RuntimeNPClass<VlcNPObject>::getClass();
}
return NPERR_NO_ERROR;