2012-07-25

How to get the current position when paused, in the embedded windows media player

The below sample code will alert the user, time elapsed, when the user press the pause button. Since it’s Windows Media player, it will only work in IE. To get it work in other browsers, you may need to install plugins/add-ons.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
    <title></title>
</head>
<body>
    <form id="Form1">
    <object id="Player" height="0" width="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
    </object>
    <input type="button" name="BtnPlay" value="Play" onclick="StartMeUp()" />
    <input type="button" name="BtnStop" value="Stop" onclick="ShutMeDown()" />
    <input type="button" name="BtnPause" value="Pause" onclick="Pause()" />
    <script type="text/javascript">
<!--

        function StartMeUp() {
            document.getElementById('Player').URL = "Danza kuduro.mp3";
        }

        function ShutMeDown() {
            document.getElementById('Player').Controls.stop();
        }

        function Pause() {
            document.getElementById('Player').Controls.Pause();
            alert(document.getElementById('Player').Controls.currentPosition);
        }

-->
    </script>
    </form>
</body>
</html>

No comments: