Create object WMPlayer.OCX issue

南笙酒味 提交于 2019-12-25 01:14:05

问题


I am using following code in my HTML page but it is returning NULL. (IE8 , MS WIndows 7 Pro)

Set Sound = CreateObject("WMPlayer.OCX")

I am sure Windows Media Player is installed and working fine.

How to fix it?


回答1:


It seems like is impossible to use Visual Basic code like I use in HTML.

Instead of it we have to use Windows Media Player in DOM like this

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

And later we must implement all methdos to Start/Stop audio/movie.

For example

 <script type="text/vbscript" language="VBScript">       
     Set oElm = document.getElementById("WindowsMediaPlayer")
                if oElm Is Nothing then
                    ' MsgBox("element does not exist")
                else
                    ' MsgBox("element exists")
                    ' MsgBox oElm
                    oElm.controls.stop()
                    oElm.URL = "C:\HTML\Sounds\oos.wav"
                end if  
<script>  


来源:https://stackoverflow.com/questions/33898204/create-object-wmplayer-ocx-issue

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