]> git.sesse.net Git - vlc/blobdiff - activex/test.html
A bit of cleanup and test
[vlc] / activex / test.html
index 897310e7e7bba94a586e87103a44c32e632b48e9..c95a6dc28c7463924c5854c35e3695b0f3c2660e 100644 (file)
 <HTML>
 <TITLE>VLC ActiveX plugin test page</TITLE>
 <BODY>
-<SCRIPT LANGUAGE="JScript">
-<!--
-function go(targetURL)
-{
-       var options = new Array(":input-repeat");
-       document.vlc.addTarget(targetURL, options, 4+8, -666);
-};
-//-->
-</SCRIPT>
 <TABLE>
-<TR><TD>
+<TR><TD colspan="2">
 MRL:
-<INPUT size="80" name="targetTextField" value="">
-<INPUT type=submit value="Go" onClick="go(targetTextField.value);">
+<INPUT size="90" name="targetTextField" value="">
+<INPUT type=submit value="Go" onClick="doGo(targetTextField.value);">
 </TD></TR>
-<TR><TD>
+<TR><TD colspan="2">
+<!--
+Insert VideoLAN.VLCPlugin.1 activex control
+-->
 <OBJECT classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"
-        width="640" height="480" id="vlc" events="True">
-<param name="Src" value="" />
+        codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,4,0"
+        width="640"
+        height="480"
+        id="vlc"
+        events="True">
+<param name="MRL" value="" />
 <param name="ShowDisplay" value="True" />
-<param name="Loop" value="False" />
+<param name="AutoLoop" value="False" />
 <param name="AutoPlay" value="False" />
+<param name="Volume" value="50" />
+<param name="StartTime" value="0" />
+</OBJECT>
+</TD></TR>
+<TR><TD>
+<!--
+Insert MSComctlLib.Slider.2 activex control
+-->
+<OBJECT classid="clsid:F08DF954-8592-11D1-B16A-00C0F0283628"
+        width="540"
+        height="20"
+        id="slider"
+        events="True">
+<param name="TickStyle" value="3" />
+<param name="Min" value="0" />
+<param name="Max" value="0" />
+<param name="Value" value="0" />
+<param name="Enabled" value="False" />
 </OBJECT>
+</TD><TD width="15%">
+<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 value="Stop" onClick='document.vlc.stop();'>
+&nbsp;
+<INPUT type=button value=" << " onClick='document.vlc.playSlower();'>
+<INPUT type=button value=" >> " onClick='document.vlc.playFaster();'>
+&nbsp;
+<INPUT type=button value="Show" onClick='document.vlc.Visible = true;'>
+<INPUT type=button value="Hide" onClick='document.vlc.Visible = false;'>
+&nbsp;
+<INPUT type=button value="Version" onClick='alert(document.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.toggleMute();'>
+</TD>
+</TR>
+</TABLE>
 <SCRIPT LANGUAGE="JScript">
 <!--
-function vlc::OnPlay()
+var sliderTimerId = 0;
+var sliderScrolling = false;
+
+document.onreadystatechange=onVLCStateChange;
+function onVLCStateChange()
+{
+    if( document.readyState == 'complete' )
+    {
+        updateVolume(0);
+    }
+};
+function updateVolume(deltaVol)
+{
+    vlc.Volume += deltaVol;
+    volumeTextField.innerText = vlc.Volume+"%";
+};
+function formatTime(timeVal)
+{
+    var timeHour = timeVal;
+    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 onPlay()
 {
-       alert("Playing");
+    document.getElementById("PlayOrPause").value = "Pause";
 };
-function vlc::OnPause()
+function onPause()
 {
-       alert("Paused");
+    document.getElementById("PlayOrPause").value = " Play ";
 };
-function vlc::OnStop()
+function onStop()
 {
-       alert("Stopped");
+    if( slider.Enabled )
+    {
+        slider.Value = slider.Min;
+        slider.Enabled = false;
+    }
+    info.innerText = "-:--:--/-:--:--";
+    document.getElementById("PlayOrPause").value = " Play ";
+};
+var liveFeedText = new Array("Live", "((Live))", "(( Live ))", "((  Live  ))");
+var liveFeedRoll = 0;
+
+function doUpdate()
+{
+    if( vlc.Playing )
+    {
+        if( ! sliderScrolling )
+        {
+            if( vlc.Length > 0 )
+            {
+                // seekable stream
+                slider.Enabled = true;
+                slider.Max = vlc.Length;
+                slider.Value = vlc.Time;
+                info.innerText = formatTime(vlc.Time)+"/"+formatTime(vlc.Length);
+                document.getElementById("PlayOrPause").Enabled = true;
+            }
+            else {
+                // non-seekable "live" stream
+                if( slider.Enabled )
+                {
+                    slider.Value = slider.Min;
+                    slider.Enabled = false;
+                }
+                liveFeedRoll = liveFeedRoll & 3;
+                info.innerText = liveFeedText[liveFeedRoll++];
+            }
+        }
+        sliderTimerId = setTimeout("doUpdate()", 1000);
+    }
+    else
+    {
+        onStop();
+        sliderTimerId = 0;
+    }
+};
+function doGo(targetURL)
+{
+       var options = new Array(":vout-filter=deinterlace", ":deinterlace-mode=linear");
+       document.vlc.addTarget(targetURL, options, 4+8, -666);
+};
+function doPlayOrPause()
+{
+    if( document.vlc.playing )
+    {
+        document.vlc.pause();
+    }
+    else
+    {
+        document.vlc.play();
+    }
+};
+function vlc::Play()
+{
+    if( ! sliderTimerId )
+    {
+        sliderTimerId = setTimeout("doUpdate()", 1000);
+    }
+    onPlay();
+};
+function vlc::Pause()
+{
+    if( sliderTimerId )
+    {
+        clearTimeout(sliderTimerId)
+        sliderTimerId = 0;
+    }
+    onPause();
+};
+function vlc::Stop()
+{
+    if( sliderTimerId )
+    {
+        clearTimeout(sliderTimerId)
+        sliderTimerId = 0;
+    }
+    onStop();
+};
+function slider::Scroll()
+{
+    slider.Text = formatTime(slider.Value);
+    info.innerText = slider.Text+"/"+formatTime(vlc.Length);
+    if( vlc.Time != slider.Value )
+    {
+        vlc.Time = slider.Value;
+    }
+};
+function slider::Change()
+{
+    if( sliderScrolling )
+    {
+        sliderScrolling = false;
+    }
+    else if( vlc.Time != slider.Value )
+    {
+        vlc.Time = slider.Value;
+    }
 };
 //-->
 </SCRIPT>
-</TD></TR>
-<TR><TD>
-<INPUT type=submit value="Play" onClick='document.vlc.play();'>
-<INPUT type=submit value="Pause" onClick='document.vlc.pause();'>
-<INPUT type=submit value="Stop" onClick='document.vlc.stop();'>
-<INPUT type=submit value=" << " onClick='document.vlc.playSlower();'>
-<INPUT type=submit value=" >> " onClick='document.vlc.playFaster();'>
-<INPUT type=submit value="Mute" onClick='document.vlc.toggleMute();'>
-<INPUT type=submit value="Show" onClick='document.vlc.Visible = true;'>
-<INPUT type=submit value="Hide" onClick='document.vlc.Visible = false;'>
-<INPUT type=submit value="Version" onClick='alert(document.vlc.VersionInfo);'>
-</TD></TR>
-</TABLE>
 </BODY>
 </HTML>