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