Create object WMPlayer.OCX issue

2.6k views Asked by At

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

There are 1 answers

0
NoWar On BEST ANSWER

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>