Commit 25323bcd authored by Damien Fouilleul's avatar Damien Fouilleul

mozilla: more clean-ups

parent f8cece22
......@@ -202,7 +202,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
{
"togglemute",
"toggleMute",
};
const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodNames)/sizeof(NPUTF8 *);
......@@ -255,8 +255,10 @@ const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
"length",
"position",
"time",
"state",
"rate",
"fps",
"hasvout",
"hasVout",
};
const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::propertyNames)/sizeof(NPUTF8 *);
......@@ -266,6 +268,8 @@ enum LibvlcInputNPObjectPropertyIds
ID_length,
ID_position,
ID_time,
ID_state,
ID_rate,
ID_fps,
ID_hasvout,
};
......@@ -281,9 +285,18 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
libvlc_input_t *p_input = libvlc_playlist_get_input(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;
if( index != ID_state )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
/* for input state, return CLOSED rather than an exception */
INT32_TO_NPVARIANT(0, result);
return INVOKERESULT_NO_ERROR;
}
}
switch( index )
......@@ -327,6 +340,32 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_state:
{
int val = libvlc_input_get_state(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;
}
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
{
float val = libvlc_input_get_rate(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;
}
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_fps:
{
double val = libvlc_input_get_fps(p_input, &ex);
......@@ -419,6 +458,29 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
{
float val;
if( NPVARIANT_IS_INT32(value) )
val = (float)NPVARIANT_TO_INT32(value);
else if( NPVARIANT_IS_DOUBLE(value) )
val = (float)NPVARIANT_TO_DOUBLE(value);
else
{
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE;
}
libvlc_input_set_rate(p_input, val, &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;
}
return INVOKERESULT_NO_ERROR;
}
}
libvlc_input_free(p_input);
}
......@@ -439,15 +501,15 @@ const int LibvlcInputNPObject::methodCount = sizeof(LibvlcInputNPObject::methodN
const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
{
"itemscount",
"isplaying",
"itemCount",
"isPlaying",
};
const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistNPObjectPropertyIds
{
ID_itemscount,
ID_itemcount,
ID_isplaying,
};
......@@ -461,7 +523,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
switch( index )
{
case ID_itemscount:
case ID_itemcount:
{
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -494,12 +556,12 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
{
"add",
"play",
"togglepause",
"togglePause",
"stop",
"next",
"prev",
"clear",
"deleteitem"
"removeItem"
};
const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);
......@@ -513,7 +575,7 @@ enum LibvlcPlaylistNPObjectMethodIds
ID_next,
ID_prev,
ID_clear,
ID_deleteitem,
ID_removeitem,
};
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -718,7 +780,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_deleteitem:
case ID_removeitem:
if( (argCount == 1) && isNumberValue(args[0]) )
{
libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);
......@@ -997,7 +1059,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
{
"togglefullscreen",
"toggleFullscreen",
};
enum LibvlcVideoNPObjectMethodIds
......
......@@ -14,27 +14,22 @@ MRL:
id="vlc">
</EMBED>
</TD></TR>
</TD><TD width="15%">
<DIV id="info" style="text-align:center">-:--:--/-:--:--</DIV>
</TD></TR>
<TR><TD colspan="2">
<TR><TD>
<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause()'>
<INPUT type=button value="Stop" onClick='document.getElementById("vlc").playlist.stop();'>
&nbsp;
<INPUT type=button value=" << " onClick='document.getElementById("vlc").playlist.playSlower();'>
<INPUT type=button value=" >> " onClick='document.getElementById("vlc").playlist.playFaster();'>
<INPUT type=button value=" << " onClick='doPlaySlower();'>
<INPUT type=button value=" >> " onClick='doPlayFaster();'>
&nbsp;
<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.getElementById("vlc").VersionInfo);'>
<INPUT type=button value="Version" onClick='alert(document.getElementById("vlc"));'>
<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.getElementById("vlc").audio.togglemute();'>
</TD>
</TR>
<INPUT type=button value="Mute" onClick='document.getElementById("vlc").audio.toggleMute();'>
</TD><TD width="15%">
<DIV id="info" style="text-align:center">-:--:--/-:--:--</DIV>
</TD></TR>
</TABLE>
<SCRIPT LANGUAGE="Javascript">
<!--
......@@ -44,7 +39,7 @@ function updateVolume(deltaVol)
{
var vlc = document.getElementById("vlc");
vlc.audio.volume += deltaVol;
volumeTextField.innerText = vlc.audio.volume+"%";
document.getElementById("volumeTextField").innerHTML = vlc.audio.volume+"%";
};
function formatTime(timeVal)
{
......@@ -72,7 +67,7 @@ function onPause()
};
function onStop()
{
info.innerText = "-:--:--/-:--:--";
document.getElementById("info").innerHTML = "-:--:--/-:--:--";
document.getElementById("PlayOrPause").value = " Play ";
};
var liveFeedText = new Array("Live", "((Live))", "(( Live ))", "(( Live ))");
......@@ -81,17 +76,17 @@ var liveFeedRoll = 0;
function doUpdate()
{
var vlc = document.getElementById("vlc");
if( vlc.playlist.isplaying )
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("info").innerHTML = formatTime(vlc.input.time/1000)+"/"+formatTime(vlc.input.length/1000);
document.getElementById("PlayOrPause").Enabled = true;
}
else {
liveFeedRoll = liveFeedRoll & 3;
info.innerText = liveFeedText[liveFeedRoll++];
document.getElementById("info").innerText = liveFeedText[liveFeedRoll++];
}
timerId = setTimeout("doUpdate()", 1000);
}
......@@ -109,7 +104,7 @@ function doGo(targetURL)
function doPlayOrPause()
{
var vlc = document.getElementById("vlc");
if( vlc.playlist.isplaying )
if( vlc.playlist.isPlaying )
{
vlc.playlist.pause();
}
......@@ -118,6 +113,16 @@ function doPlayOrPause()
vlc.playlist.play();
}
};
function doPlaySlower()
{
var vlc = document.getElementById("vlc");
vlc.input.rate = vlc.input.rate / 2;
};
function doPlayFaster()
{
var vlc = document.getElementById("vlc");
vlc.input.rate = vlc.input.rate * 2;
};
function vlcPlayEvent()
{
if( ! timerId )
......
......@@ -621,9 +621,7 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0));
TextOut( hdc, (rect.right-rect.left)/ 2 - 40,
(rect.bottom-rect.top)/ 2,
WINDOW_TEXT, strlen(WINDOW_TEXT) );
DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
EndPaint( p_hwnd, &paintstruct );
return 0L;
......
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