Start/Stop methods for embeded Windows Media Playe

2019-09-19 02:32发布

问题:

I have following code working fine.

<object   classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer" 
width="242" height="202" style="position:absolute; left:1;top:1;">
  <param name="URL" value="C:\HTML\Sounds\oos.wav">
  <param name="autoStart" value="0">
</object>

I would like to crearte Start/Stop methods in VBScript for this object.

So I am doing like

 Sub Start
            Dim oElm 
            Set oElm = document.getElementById("WindowsMediaPlayer")
            if oElm Is Nothing then
                MsgBox("element does not exist")
            else
               ' MsgBox("element exists")
                oElm.controls.play();
            end if

 End sub  

But it does not work.

How to fix it?

回答1:

It shoul dbe done like this

<object   classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer" width="0" height="0">
</object>


Sub Start
            Dim oElm 
            Set oElm = document.getElementById("WindowsMediaPlayer")
            if oElm Is Nothing then
                MsgBox("element does not exist")
            else
                oElm.controls.stop()
                oElm.URL = "C:\HTML\Sounds\oos.wav"
            end if

 End sub