WMP not displaying with DHTML

I am trying to display Windows Media Player embedded in a page using the

technique described in the MS Knowledge base - calling a Javascript function

to load it, thereby avoiding the 'Click here to activate' message.

My code is straightforward:

<div Id="Movie"></div>

<script lang='Javascript'>

createMediaPlayer("Movie","mymovie.wmv",320,240);

</script>

with the createMediaPlayer function in a linked js file:

function createMediaPlayer(DivID,movie,width,height)

{

var d = document.getElementById(DivID);

d.InnerHTML = '<OBJECT ID="MediaPlayer" WIDTH=' + width + ' HEIGHT=' +

height + ' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"' +

'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"' +

'standby="Loading Microsoft Windows Media Player components..."' +

'type="application/x-oleobject">' +

'<PARAM NAME="FileName" VALUE="' + movie + '">' +

'<PARAM NAME="ShowControls" VALUE="1">' +

'<PARAM NAME="ShowDisplay" VALUE="1">' +

'<PARAM NAME="ShowStatusBar" VALUE="1">' +

'<PARAM NAME="AutoSize" VALUE="1">' +

'<Embed type="application/x-mplayer2"' +


'pluginspage="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx/"' +

'filename="' + movie + '"' +

'src="' + movie + '"' +

'Name=MediaPlayer' +

'ShowControls=1' +

'ShowDisplay=1' +

'ShowStatusBar=1' +

'width=' + width +

' height=' + height + '></embed></OBJECT>';

}

The code runs correctly but the WMP object never displays. I have put in an

alert to show the DIV's inner HTML and that is correct so I know the

javascript function is running.

I use the same technique to display Flash objects and they work fine.

The code for them is:

<div Id="Flash"></div>

<script lang='Javascript'>

createFlashControl("Flash","myflash.swf",320,240);

</script>

and

function createFlashControl(DivID,movie,width,height)

{

var d = document.getElementById(DivID);

d.innerHTML = '<object

classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"

codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'

+ width + '" height="' + height + '" id="Shell" align="middle"><param

name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'

+ movie + '" /><param name="quality" value="high"/><embed src="' +

movie + '" quality="high" width="' + width + '" height="' + height

+ '" name="Shell" align="middle" allowScriptAccess="sameDomain"

type="application/x-shockwave-flash"

pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';

}

Anyone got any suggestions as to what I am doing wrong?

Thanks.

[3995 byte] By [Burstock] at [2008-2-13]