Using Javascript variable in object tag (WMP)

Status
Not open for further replies.
Hi,

I'm updating a javascript variable on the onchange function of a select box. I need this updated value to enter into a parameter for windows media player 6.4, this is what I currently have:

Code:
<script language="javascript">
  //for this example I hardcode the video field 
  var video_name = "http://myserver/myvideo.mpg";
</script>

<OBJECT ID="video" width=176 height=144>
  <PARAM NAME="AutoStart" VALUE="True">
  <PARAM NAME="Filename" VALUE="' + video_name + '">
</OBJECT>


This does not seem to be working. I think my syntax is wrong although I get no javascript errors, just an error in the media player saying 'file not found'. Any ideas?

thanks
 

Ruinous

Ars Tribunus Angusticlavius
6,596
I would assign the PARAM an ID, then reference it within the JavaScript by document.getElementById(%ID_FOR_PARAM%).value, see if that works.

Otherwise, I would suggest an IFRAME.

EDIT: MSDN says that the value property of a PARAM tag is only read/write as of IE6, so if you're going after cross-platform functionality, you may want to consider the IFRAME route.

OYBB
 
Ruinous, thanks for the reply and the linkage. I tried added an ID to the filename parameter but still no go.

Here's something odd, I was using the WMP 7.0 object and I was able to change the URL parameter dynamically. This was working fine codewise as it would play the video people would select in the select box. However on some machines it wouldn't work at all (IE 6, WMP 8, WINXP), so I thought this was a problem using the WMP 7 version and decided to try and go with 6.4 which is what I'm currently doing.

The one noticable change is the parameter changed from "URL" to "Filename" and that is where my problems are happening. When I read the MSDN article on how it's only read/write in IE 6 I found that strange since it seemed I could already do that.
 

Ruinous

Ars Tribunus Angusticlavius
6,596
Hm, I don't know. I've hardly played with OBJECTs, so I really don't know the dynamism of the parameters. It's possible that the PARAMs are childNodes to the OBJECT, so you could try:

Code:
document.getElementById("video").Filename.value = video_name;

The other thing I can think of is this:

Code:
document.getElementById("video").getElementsByTagName("PARAM").item(1).value = video_name;

Note that the item(1) corresponds to then Filename PARAM being the second PARAM within the object tag. (The AutoStart PARAM would be item(0), by comparison.)

Hope this helps.

OYBB
 
Status
Not open for further replies.