0

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?

NoWar
  • 36,338
  • 80
  • 323
  • 498
  • It's not registered perhaps?, this kind of goes back to your previous question about [`CreateObject()`](http://stackoverflow.com/q/33874736/692942). Same applies, is it x86 or x64? Is is registered using the correct `regsvr32.exe`? Does the `ProgId` exist in the registry `HKLM\Software\Classes` or `HKLM\Software\Wow6432Node\Classes`? Just a couple of questions you need to look at. – user692942 Nov 24 '15 at 16:11
  • @Lankymart How it should be registered? Would you mind to provide link do download `WMPlayer.OCX`, please. – NoWar Nov 24 '15 at 16:22

1 Answers1

0

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>  
NoWar
  • 36,338
  • 80
  • 323
  • 498