-1

I want to automatically open URL on the same page after my media player avi file finish and here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>WELCOME TO LOTUS TENDA WEBSITE</title>
</head>
<body bgcolor="#000000">
<br><br>
<table border="0" align=center>
   <tr>
     <td> 
     <object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"

standby="Loading Microsoft Windows® Media Player components..." type="application/x-oleobject" width="890" height="500">
<param name="fileName" value="intro.avi">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="false">
<param name="Volume" value="-450">
<embed type="application/x-mplayer2" 
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="intro.avi" 
name="MediaPlayer1" width=890 height=500 autostart=1 showcontrols=0 volume=-450>
</object>
     </td>
       </tr>
 </table>
</body>
</html>
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497

2 Answers2

0
setInterval(function () {
                if ($("MediaPlayer1")[0].playState == 1) {
                    $("MediaPlayer1")[0].URL = "nextVideo.wmv";
                }
            }, 100);
Maxpan
  • 563
  • 5
  • 8
0

This can be done with JavaScript by sampling the PlayState property of the object. From quick test that I conducted, it will be 2 before the video started playing, 3 while it's playing and 0 when the video finished playing.

Add this inside your <head> section:

<script type="text/javascript">
window.onload = function() {
    var oVid = document.getElementById("MediaPlayer1");
    window.setTimeout(function CheckVidState() {
        if (oVid.PlayState == 0) {
            document.location = "OtherPage.html";
            return true;
        }
        window.setTimeout(CheckVidState, 10);
        return false;
    }, 10);
};
</script>

This will redirect the user to OtherPage.html when the video finished playing.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208