+#endif /* XP_MACOSX */
+
+ /* common settings */
+ ppsz_argv[ppsz_argc++] = "-vv";
+ ppsz_argv[ppsz_argc++] = "--no-stats";
+ ppsz_argv[ppsz_argc++] = "--no-media-library";
+ ppsz_argv[ppsz_argc++] = "--intf";
+ ppsz_argv[ppsz_argc++] = "dummy";
+
+ const char *progid = NULL;
+
+ /* parse plugin arguments */
+ for( int i = 0; i < argc ; i++ )
+ {
+ fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]);
+
+ if( !strcmp( argn[i], "target" )
+ || !strcmp( argn[i], "mrl")
+ || !strcmp( argn[i], "filename")
+ || !strcmp( argn[i], "src") )
+ {
+ psz_target = argv[i];
+ }
+ else if( !strcmp( argn[i], "autoplay")
+ || !strcmp( argn[i], "autostart") )
+ {
+ b_autoplay = boolValue(argv[i]);
+ }
+ else if( !strcmp( argn[i], "fullscreen" ) )
+ {
+ if( boolValue(argv[i]) )
+ {
+ ppsz_argv[ppsz_argc++] = "--fullscreen";
+ }
+ else
+ {
+ ppsz_argv[ppsz_argc++] = "--no-fullscreen";
+ }
+ }
+ else if( !strcmp( argn[i], "mute" ) )
+ {
+ if( boolValue(argv[i]) )
+ {
+ ppsz_argv[ppsz_argc++] = "--volume";
+ ppsz_argv[ppsz_argc++] = "0";
+ }
+ }
+ else if( !strcmp( argn[i], "loop")
+ || !strcmp( argn[i], "autoloop") )
+ {
+ if( boolValue(argv[i]) )
+ {
+ ppsz_argv[ppsz_argc++] = "--loop";
+ }
+ else {
+ ppsz_argv[ppsz_argc++] = "--no-loop";
+ }
+ }
+ else if( !strcmp( argn[i], "version")
+ || !strcmp( argn[i], "progid") )
+ {
+ progid = argv[i];
+ }
+ }
+
+ libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, NULL);
+ if( ! libvlc_instance )
+ {
+ return NPERR_GENERIC_ERROR;
+ }
+
+ /*
+ ** fetch plugin base URL, which is the URL of the page containing the plugin
+ ** this URL is used for making absolute URL from relative URL that may be
+ ** passed as an MRL argument
+ */
+ NPObject *plugin;
+
+ if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
+ {
+ /*
+ ** is there a better way to get that info ?
+ */
+ static const char docLocHref[] = "document.location.href";
+ NPString script;
+ NPVariant result;
+
+ script.utf8characters = docLocHref;
+ script.utf8length = sizeof(docLocHref)-1;
+
+ if( NPN_Evaluate(p_browser, plugin, &script, &result) )
+ {
+ if( NPVARIANT_IS_STRING(result) )
+ {
+ NPString &location = NPVARIANT_TO_STRING(result);
+
+ psz_baseURL = new char[location.utf8length+1];
+ if( psz_baseURL )
+ {
+ strncpy(psz_baseURL, location.utf8characters, location.utf8length);
+ psz_baseURL[location.utf8length] = '\0';
+ }
+ }
+ NPN_ReleaseVariantValue(&result);
+ }
+ NPN_ReleaseObject(plugin);
+ }
+
+ if( psz_target )
+ {
+ // get absolute URL from src
+ char *psz_absurl = getAbsoluteURL(psz_target);
+ psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
+ }
+
+ /* assign plugin script root class */
+ if( (NULL != progid) && (!strcmp(progid, "VideoLAN.VLCPlugin.2")) )
+ {
+ /* new APIs */
+ p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
+ }
+ else
+ {
+ /* legacy APIs */
+ p_scriptClass = RuntimeNPClass<VlcNPObject>::getClass();
+ }
+
+ return NPERR_NO_ERROR;