Start/Stop methods for embeded Windows Media Player via VBScript

微笑、不失礼 提交于 2020-01-25 12:46:41

问题


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  


来源:https://stackoverflow.com/questions/33899776/start-stop-methods-for-embeded-windows-media-player-via-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!