Commit df9d73dd authored by Damien Fouilleul's avatar Damien Fouilleul

- compatibility fixes for FireFox, Safari and Opera 9

- fixed a couple of crashes on MacOS X
parent 4902ffc9
......@@ -494,7 +494,7 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
{
"add",
"play",
"togglepause"
"togglepause",
"stop",
"next",
"prev",
......@@ -811,63 +811,59 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, cha
void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options, char*** ppsz_options)
{
/* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
NPVariant value;
/* we are expecting to have a Javascript Array object */
NPIdentifier name = NPN_GetStringIdentifier("length");
if( NPN_HasProperty(_instance, obj, name) )
NPIdentifier propId = NPN_GetStringIdentifier("length");
if( NPN_GetProperty(_instance, obj, propId, &value) )
{
NPVariant value;
if( NPN_GetProperty(_instance, obj, name, &value) )
{
int count = numberValue(value);
NPN_ReleaseVariantValue(&value);
int count = numberValue(value);
NPN_ReleaseVariantValue(&value);
if( count )
if( count )
{
long capacity = 16;
char **options = (char **)malloc(capacity*sizeof(char *));
if( options )
{
long capacity = 16;
char **options = (char **)malloc(capacity*sizeof(char *));
if( options )
int nOptions = 0;
while( nOptions < count )
{
int nOptions = 0;
propId = NPN_GetIntIdentifier(nOptions);
if( ! NPN_GetProperty(_instance, obj, propId, &value) )
/* return what we got so far */
break;
while( nOptions < count )
if( ! NPVARIANT_IS_STRING(value) )
{
name = NPN_GetIntIdentifier(nOptions);
if( ! NPN_HasProperty(_instance, obj, name) )
/* return what we got so far */
break;
if( ! NPN_GetProperty(_instance, obj, name, &value) )
/* return what we got so far */
break;
/* return what we got so far */
NPN_ReleaseVariantValue(&value);
break;
}
if( ! NPVARIANT_IS_STRING(value) )
if( nOptions == capacity )
{
capacity += 16;
char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
if( ! moreOptions )
{
/* return what we got so far */
/* failed to allocate more memory */
NPN_ReleaseVariantValue(&value);
/* return what we got so far */
*i_options = nOptions;
*ppsz_options = options;
break;
}
if( nOptions == capacity )
{
capacity += 16;
char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
if( ! moreOptions )
{
/* failed to allocate more memory */
NPN_ReleaseVariantValue(&value);
/* return what we got so far */
*i_options = nOptions;
*ppsz_options = options;
break;
}
options = moreOptions;
}
options[nOptions++] = stringValue(value);
options = moreOptions;
}
*i_options = nOptions;
*ppsz_options = options;
options[nOptions++] = stringValue(value);
}
*i_options = nOptions;
*ppsz_options = options;
}
}
}
......
This diff is collapsed.
......@@ -19,20 +19,20 @@ MRL:
</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="Stop" onClick='document.getElementById("vlc").playlist.stop();'>
&nbsp;
<INPUT type=button value=" << " onClick='document.vlc.playlist.playSlower();'>
<INPUT type=button value=" >> " onClick='document.vlc.playlist.playFaster();'>
<INPUT type=button value=" << " onClick='document.getElementById("vlc").playlist.playSlower();'>
<INPUT type=button value=" >> " onClick='document.getElementById("vlc").playlist.playFaster();'>
&nbsp;
<INPUT type=button value="Show" onClick='document.vlc.visible = true;'>
<INPUT type=button value="Hide" onClick='document.vlc.visible = false;'>
<INPUT type=button value="Show" onClick='document.getElementById("vlc").visible = true;'>
<INPUT type=button value="Hide" onClick='document.getElementById("vlc").visible = false;'>
&nbsp;
<INPUT type=button value="Version" onClick='alert(document.vlc.VersionInfo);'>
<INPUT type=button value="Version" onClick='alert(document.getElementById("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();'>
<INPUT type=button value="Mute" onClick='document.getElementById("vlc").audio.togglemute();'>
</TD>
</TR>
</TABLE>
......@@ -42,9 +42,9 @@ var timerId = 0;
function updateVolume(deltaVol)
{
var plugin = document.getElementById('vlc');
plugin.audio.volume += deltaVol;
volumeTextField.innerText = plugin.audio.volume+"%";
var vlc = document.getElementById("vlc");
vlc.audio.volume += deltaVol;
volumeTextField.innerText = vlc.audio.volume+"%";
};
function formatTime(timeVal)
{
......@@ -80,6 +80,7 @@ var liveFeedRoll = 0;
function doUpdate()
{
var vlc = document.getElementById("vlc");
if( vlc.playlist.isplaying )
{
if( vlc.input.length > 0 )
......@@ -103,17 +104,18 @@ function doUpdate()
function doGo(targetURL)
{
var options = new Array(":vout-filter=deinterlace", ":deinterlace-mode=linear");
document.vlc.playlist.add(targetURL, null, options);
document.getElementById("vlc").playlist.add(targetURL, null, options);
};
function doPlayOrPause()
{
if( document.vlc.playlist.isplaying )
var vlc = document.getElementById("vlc");
if( vlc.playlist.isplaying )
{
document.vlc.playlist.pause();
vlc.playlist.pause();
}
else
{
document.vlc.playlist.play();
vlc.playlist.play();
}
};
function vlcPlayEvent()
......
......@@ -176,10 +176,11 @@ int16 NPP_HandleEvent( NPP instance, void * event )
}
}
}
if( needsDisplay )
{
const NPWindow *npwindow = p_plugin->getWindow();
const NPWindow *npwindow = p_plugin->getWindow();
if( needsDisplay && npwindow->window )
{
/* draw the beautiful "No Picture" */
ForeColor(blackColor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment