Commit 1819b6e0 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Baptiste Kempf

mozilla: activex: update test.html

- use VLC MediaPlayer events
- use unix style EOL
parent 39e11285
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HTML>
<TITLE>VLC Plugin test page</TITLE>
<STYLE>
.inputTrackerInput {
height:20;
width:30;
font-family : Arial, Helvetica, sans-serif;
font-size : 12px;
}
</STYLE>
<SCRIPT type="text/javascript" src="blueshoes-4.5/javascript/lib/LibCrossBrowser.js"></SCRIPT>
<SCRIPT type="text/javascript" src="blueshoes-4.5/javascript/lib/EventHandler.js"></SCRIPT>
<SCRIPT type="text/javascript" src="blueshoes-4.5/javascript/core/form/Bs_FormUtil.lib.js"></SCRIPT>
<SCRIPT type="text/javascript" src="blueshoes-4.5/javascript/components/slider/Bs_Slider.class.js"></SCRIPT>
<SCRIPT language="JavaScript"><!--
function init()
{
inputTracker = new Bs_Slider();
if (inputTracker)
{
inputTracker.attachOnChange(onInputTrackerChange);
inputTracker.attachOnSlideStart(onInputTrackerScrollStart);
inputTracker.attachOnSlideEnd(onInputTrackerScrollEnd);
inputTracker.width = 530;
inputTracker.height = 15;
inputTracker.minVal = 0;
inputTracker.maxVal = 1.0;
inputTracker.valueDefault = 0;
inputTracker.valueInterval = 1/530;
inputTracker.setDisabled(true);
inputTracker.imgDir = 'blueshoes-4.5/javascript/components/slider/img/';
inputTracker.setBackgroundImage('aluminumalloyvolcanic/horizontal_background.gif', 'repeat');
inputTracker.setArrowIconLeft('aluminumalloyvolcanic/horizontal_backgroundLeft.gif', 2, 19);
inputTracker.setArrowIconRight('aluminumalloyvolcanic/horizontal_backgroundRight.gif', 2, 19);
inputTracker.setSliderIcon('aluminumalloyvolcanic/horizontal_knob.gif', 15, 19);
inputTracker.useInputField = 0;
inputTracker.draw('inputTrackerDiv');
}
if( navigator.appName.indexOf("Microsoft Internet")==-1 )
{
onVLCPluginReady()
......@@ -43,37 +78,212 @@ function getVLC(name)
}
}
function registerVLCEvent(event, handler)
{
var vlc = getVLC("vlc");
if (vlc) {
if (vlc.attachEvent) {
// Microsoft
vlc.attachEvent (event, handler);
} else if (vlc.addEventListener) {
// Mozilla: DOM level 2
vlc.addEventListener (event, handler, true);
} else {
// DOM level 0
eval("vlc.on" + event + " = handler");
}
}
}
function unregisterVLCEvent(event, handler)
{
var vlc = getVLC("vlc");
if (vlc) {
if (vlc.detachEvent) {
// Microsoft
vlc.detachEvent (event, handler);
} else if (vlc.removeEventListener) {
// Mozilla: DOM level 2
vlc.removeEventListener (event, handler, true);
} else {
// DOM level 0
eval("vlc.on" + event + " = null");
}
}
}
// JS VLC API callbacks
function handleMediaPlayerMediaChanged()
{
document.getElementById("info").innerHTML = "Media Changed";
}
function handle_MediaPlayerNothingSpecial()
{
document.getElementById("state").innerHTML = "Idle...";
}
function handle_MediaPlayerOpening()
{
onOpen();
}
function handle_MediaPlayerBuffering(val)
{
document.getElementById("info").innerHTML = val + "%";
}
function handle_MediaPlayerPlaying()
{
onPlay();
}
function handle_MediaPlayerPaused()
{
onPause();
}
function handle_MediaPlayerStopped()
{
onStop();
}
function handle_MediaPlayerForward()
{
document.getElementById("state").innerHTML = "Forward...";
}
function handle_MediaPlayerBackward()
{
document.getElementById("state").innerHTML = "Backward...";
}
function handle_MediaPlayerEndReached()
{
onEnd();
}
function handle_MediaPlayerEncounteredError()
{
onError();
}
function handle_MediaPlayerTimeChanged(time)
{
var vlc = getVLC("vlc");
var info = document.getElementById("info");
if( vlc )
{
var mediaLen = vlc.input.length;
if( mediaLen > 0 )
{
// seekable media
info.innerHTML = formatTime(time)+"/"+formatTime(mediaLen);
}
}
}
function handle_MediaPlayerPositionChanged(val)
{
// set javascript slider to correct position
}
function handle_MediaPlayerSeekableChanged(val)
{
setSeekable(val);
}
function handle_MediaPlayerPausableChanged(val)
{
setPauseable(val);
}
function handle_MediaPlayerTitleChanged(val)
{
//setTitle(val);
document.getElementById("info").innerHTML = "Title: " + val;
}
function handle_MediaPlayerLengthChanged(val)
{
//setMediaLength(val);
}
// VLC Plugin
function onVLCPluginReady()
{
updateVolume(0);
registerVLCEvent("MediaPlayerMediaChanged", handleMediaPlayerMediaChanged);
registerVLCEvent("MediaPlayerNothingSpecial", handle_MediaPlayerNothingSpecial);
registerVLCEvent("MediaPlayerOpening", handle_MediaPlayerOpening);
registerVLCEvent("MediaPlayerBuffering", handle_MediaPlayerBuffering);
registerVLCEvent("MediaPlayerPlaying", handle_MediaPlayerPlaying);
registerVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
registerVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
registerVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
registerVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
registerVLCEvent("MediaPlayerEndReached", handle_MediaPlayerEndReached);
registerVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);
registerVLCEvent("MediaPlayerTimeChanged", handle_MediaPlayerTimeChanged);
registerVLCEvent("MediaPlayerPositionChanged", handle_MediaPlayerPositionChanged);
registerVLCEvent("MediaPlayerSeekableChanged", handle_MediaPlayerSeekableChanged);
registerVLCEvent("MediaPlayerPausableChanged", handle_MediaPlayerPausableChanged);
registerVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
registerVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
}
function close()
{
unregisterVLCEvent('MediaPlayerMouseGrab', handleMouseGrab);
unregisterVLCEvent('MediaPlayerMouseRelease', handleMouseRelease);
unregisterVLCEvent('MediaPlayerMouseClick', handleMouseClick);
unregisterVLCEvent("MediaPlayerMediaChanged", handleMediaPlayerMediaChanged);
unregisterVLCEvent("MediaPlayerNothingSpecial", handle_MediaPlayerNothingSpecial);
unregisterVLCEvent("MediaPlayerOpening", handle_MediaPlayerOpening);
unregisterVLCEvent("MediaPlayerBuffering", handle_MediaPlayerBuffering);
unregisterVLCEvent("MediaPlayerPlaying", handle_MediaPlayerPlaying);
unregisterVLCEvent("MediaPlayerPaused", handle_MediaPlayerPaused);
unregisterVLCEvent("MediaPlayerStopped", handle_MediaPlayerStopped);
unregisterVLCEvent("MediaPlayerForward", handle_MediaPlayerForward);
unregisterVLCEvent("MediaPlayerBackward", handle_MediaPlayerBackward);
unregisterVLCEvent("MediaPlayerEndReached", handle_MediaPlayerEndReached);
unregisterVLCEvent("MediaPlayerEncounteredError", handle_MediaPlayerEncounteredError);
unregisterVLCEvent("MediaPlayerTimeChanged", handle_MediaPlayerTimeChanged);
unregisterVLCEvent("MediaPlayerPositionChanged", handle_MediaPlayerPositionChanged);
unregisterVLCEvent("MediaPlayerSeekableChanged", handle_MediaPlayerSeekableChanged);
unregisterVLCEvent("MediaPlayerPausableChanged", handle_MediaPlayerPausableChanged);
unregisterVLCEvent("MediaPlayerTitleChanged", handle_MediaPlayerTitleChanged);
unregisterVLCEvent("MediaPlayerLengthChanged", handle_MediaPlayerLengthChanged);
}
//--></SCRIPT>
<BODY onLoad="init();">
<TABLE>
<TR><TD colspan="2">
MRL:
<INPUT size="90" id="targetTextField" value="">
<INPUT type=submit value="Go" onClick="doGo(document.getElementById('targetTextField').value);">
<BODY onLoad="init();" onClose="close();>
<TABLE>
<TR><TD colspan="2">
MRL:
<INPUT size="90" id="targetTextField" value="">
<INPUT type=submit value="Go" onClick="doGo(document.getElementById('targetTextField').value);">
<INPUT type=submit value="Add" onClick="doAdd(document.getElementById('targetTextField').value);">
</TD></TR>
</TD></TR>
<TR><TD align="center" colspan="2">
<!--
<!--
Insert VideoLAN.VLCPlugin.2
-->
<OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
width="640"
height="480"
id="vlc"
events="True">
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
-->
<OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
width="640"
height="480"
id="vlc"
events="True">
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
<param name="toolbar" value="true" />
<param name="StartTime" value="0" />
<param name="StartTime" value="0" />
<EMBED pluginspage="http://www.videolan.org"
type="application/x-vlc-plugin"
version="VideoLAN.VLCPlugin.2"
......@@ -83,35 +293,36 @@ Insert VideoLAN.VLCPlugin.2
text="Waiting for video"
name="vlc">
</EMBED>
</OBJECT>
</TD></TR>
</OBJECT>
</TD></TR>
<TR><TD colspan="2">
<TABLE><TR>
<TD valign="top" width="550">
<!--
<!--
Insert Slider widget
-->
</TD><TD width="15%">
<DIV id="info" style="text-align:center">-:--:--/-:--:--</DIV>
-->
<DIV id="inputTrackerDiv"</DIV>
</TD><TD width="15%">
<DIV id="info" style="text-align:center">-:--:--/-:--:--</DIV>
<DIV id="state" style="text-align:center">Stopped...</DIV>
</TD></TR></TABLE>
</TD></TR>
</TD></TR>
<TR><TD>
<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause();'>
<INPUT type=button value="Stop" onClick='doStop();'>
&nbsp;
<INPUT type=button value=" << " onClick='doPlaySlower();'>
<INPUT type=button id="PlayOrPause" value=" Play " onClick='doPlayOrPause();'>
<INPUT type=button value="Stop" onClick='doStop();'>
&nbsp;
<INPUT type=button value=" << " onClick='doPlaySlower();'>
<INPUT type=button value="Reverse" onClick='doReverse();'>
<INPUT type=button value=" >> " onClick='doPlayFaster();'>
<INPUT type=button value=" >> " onClick='doPlayFaster();'>
&nbsp;
<INPUT type=button value="Fullscreen" onClick='getVLC("vlc").video.toggleFullscreen();'>
<INPUT type=button value="Version" onClick='alert("vlc " + getVLC("vlc").VersionInfo);'>
<INPUT type=button value=" State " onClick='alert("state: " + getVLC("vlc").input.state);'>
</TD><TD align="right">
<SPAN style="text-align:center">Volume:</SPAN>
<INPUT type=button value=" - " onClick='updateVolume(-10)'>
<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=" + " onClick='updateVolume(+10)'>
<INPUT type=button value="Mute" onClick='getVLC("vlc").audio.toggleMute();'>
</TD>
</TR>
......@@ -156,8 +367,8 @@ Insert Slider widget
<TD>
<INPUT type=button value="set slider" onClick='doSetSlider();'>
<INPUT type=button value="get position" onClick='doGetPosition();'>
</TD>
</TR>
</TD>
</TR>
<TR>
<TD>Video Subtitle:
<INPUT type=button value=" + " onClick='doSubtitle(1);'>
......@@ -207,7 +418,7 @@ Insert Slider widget
<OPTION value=7>Y</OPTION>
</SELECT>
</TD>
</TR>
</TR>
<TR>
<TD>
<INPUT type=button id="telx" value="Teletext off" onClick='doToggleTeletext();'>
......@@ -215,13 +426,29 @@ Insert Slider widget
<INPUT size=4 value="100" id="telxPage" onClick='doTelxPage(document.getElementById("telxPage").value);'>
</TD>
</TR>
</TABLE>
<SCRIPT language="javascript">
<!--
</TABLE>
<SCRIPT language="javascript">
<!--
var rate = 0;
var prevState = 0;
var prevState = 0;
var monitorTimerId = 0;
var inputTracker;
var inputTrackerScrolling = false;
var inputTrackerIgnoreChange = false;
var telxState = false;
var canPause = true;
var canSeek = true;
function setPauseable(val)
{
canPause = val;
}
function setSeekable(val)
{
canSeek = val;
}
function doSetSlider()
{
......@@ -340,8 +567,8 @@ function doPlaylistClearAll()
}
}
function updateVolume(deltaVol)
{
function updateVolume(deltaVol)
{
var vlc = getVLC("vlc");
if( vlc )
{
......@@ -350,24 +577,24 @@ function updateVolume(deltaVol)
}
}
function formatTime(timeVal)
{
function formatTime(timeVal)
{
if( typeof timeVal != 'number' )
return "-:--:--";
var timeHour = Math.round(timeVal / 1000);
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;
var timeHour = Math.round(timeVal / 1000);
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 doState()
......@@ -420,47 +647,47 @@ function doState()
}
}
function monitor()
{
function monitor()
{
var vlc = getVLC("vlc");
var newState = 0;
if( vlc )
{
{
newState = vlc.input.state;
}
}
if( prevState != newState )
{
if( newState == 0 )
{
if( prevState != newState )
{
if( newState == 0 )
{
// current media has stopped
onEnd();
}
else if( newState == 1 )
{
// current media is openning/connecting
onOpen();
}
else if( newState == 2 )
{
// current media is buffering data
onBuffer();
}
else if( newState == 3 )
{
// current media is now playing
onPlay();
}
}
else if( newState == 1 )
{
// current media is openning/connecting
onOpen();
}
else if( newState == 2 )
{
// current media is buffering data
onBuffer();
}
else if( newState == 3 )
{
// current media is now playing
onPlay();
}
else if( newState == 4 )
{
// current media is now paused
onPause();
}
{
// current media is now paused
onPause();
}
else if( newState == 5 )
{
// current media has stopped
onStop();
onStop();
}
else if( newState == 6 )
{
......@@ -472,19 +699,23 @@ function monitor()
// current media encountered error
onError();
}
prevState = newState;
}
else if( newState == 3 )
{
// current media is playing
onPlaying();
}
};
/* actions */
function doGo(targetURL)
{
prevState = newState;
}
else if( newState == 3 )
{
// current media is playing
onPlaying();
}
if( monitorTimerId == 0 )
{
monitorTimerId = setInterval("monitor()", 1000);
}
};
/* actions */
function doGo(targetURL)
{
var vlc = getVLC("vlc");
if( vlc )
......@@ -502,7 +733,10 @@ function doGo(targetURL)
{
// play MRL
vlc.playlist.playItem(itemId);
monitor();
if( monitorTimerId == 0 )
{
monitor();
}
}
else
{
......@@ -524,120 +758,56 @@ function doAdd(targetURL)
}
}
function doPlayOrPause()
{
function doPlayOrPause()
{
var vlc = getVLC("vlc");
if( vlc )
{
if( vlc.playlist.isPlaying )
if( vlc.playlist.isPlaying && canPause )
{
vlc.playlist.togglePause();
monitor();
//monitor();
}
else if( vlc.playlist.items.count > 0 )
{
vlc.playlist.play();
monitor();
//monitor();
}
else
{
alert('nothing to play !');
}
}
}
}
function doStop()
{
function doStop()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.playlist.stop();
onStop();
if( monitorTimerId != 0 )
{
clearInterval(monitorTimerId);
monitorTimerId = 0;
}
onStop();
}
function doPlaySlower()
{
function doPlaySlower()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.input.rate = vlc.input.rate / 2;
}
function doPlayFaster()
{
function doPlayFaster()
{
var vlc = getVLC("vlc");
if( vlc )
vlc.input.rate = vlc.input.rate * 2;
}
/* events */
function onOpen()
{
document.getElementById("state").innerHTML = "Opening...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onBuffer()
{
document.getElementById("state").innerHTML = "Buffering...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onPlay()
{
document.getElementById("state").innerHTML = "Playing...";
document.getElementById("PlayOrPause").value = "Pause";
onPlaying();
}
function onEnd()
{
document.getElementById("state").innerHTML = "End...";
doStop();
}
var liveFeedText = ["Live", "((Live))", "(( Live ))", "(( Live ))"];
var liveFeedRoll = 0;
function onPlaying()
{
var vlc = getVLC("vlc");
var info = document.getElementById("info");
if( vlc )
{
var mediaLen = vlc.input.length;
if( mediaLen > 0 )
{
info.innerHTML = formatTime(vlc.input.time)+"/"+formatTime(mediaLen);
}
else
{
// non-seekable "live" media
liveFeedRoll = liveFeedRoll & 3;
info.innerHTML = liveFeedText[liveFeedRoll++];
}
}
}
}
function onPause()
{
document.getElementById("state").innerHTML = "Paused...";
document.getElementById("PlayOrPause").value = " Play ";
}
function onStop()
{
document.getElementById("info").innerHTML = "-:--:--/-:--:--";
document.getElementById("state").innerHTML = "Stopped...";
document.getElementById("PlayOrPause").value = " Play ";
}
function onError()
{
document.getElementById("state").innerHTML = "Error...";
}
function doMarqueeOption(option, value)
{
......@@ -689,7 +859,138 @@ function doLogoOption(option, value)
}
}
//-->
</SCRIPT>
</BODY>
</HTML>
/* events */
function onOpen()
{
document.getElementById("state").innerHTML = "Opening...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onBuffer()
{
document.getElementById("state").innerHTML = "Buffering...";
document.getElementById("PlayOrPause").value = "Pause";
}
function onPlay()
{
document.getElementById("state").innerHTML = "Playing...";
document.getElementById("PlayOrPause").value = "Pause";
onPlaying();
}
function onEnd()
{
document.getElementById("state").innerHTML = "End...";
}
var liveFeedText = ["Live", "((Live))", "(( Live ))", "(( Live ))"];
var liveFeedRoll = 0;
function onPlaying()
{
if( !inputTrackerScrolling )
{
var vlc = getVLC("vlc");
var info = document.getElementById("info");
if( vlc )
{
var mediaLen = vlc.input.length;
inputTrackerIgnoreChange = true;
if( mediaLen > 0 )
{
// seekable media
if( inputTracker )
{
if( inputTracker.maxVal == 1.0 )
{
inputTracker.setDisabled(false);
inputTracker.maxVal = 1.0;
}
inputTracker.setValue(vlc.input.position);
}
info.innerHTML = formatTime(vlc.input.time)+"/"+formatTime(mediaLen);
}
else
{
// non-seekable "live" media
if( inputTracker )
{
if( inputTracker.maxVal != 0.0 )
{
inputTracker.maxVal = 0.0;
inputTracker.setValue(0.0);
inputTracker.setDisabled(true);
}
}
liveFeedRoll = liveFeedRoll & 3;
info.innerHTML = liveFeedText[liveFeedRoll++];
}
inputTrackerIgnoreChange = false;
}
}
}
function onPause()
{
document.getElementById("state").innerHTML = "Paused...";
document.getElementById("PlayOrPause").value = " Play ";
}
function onStop()
{
var vlc = getVLC("vlc");
if( inputTracker )
{
if( !inputTracker.disabled )
{
inputTracker.setValue(inputTracker.minVal);
inputTracker.setDisabled(true);
}