views:

929

answers:

3

I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this:

<object id="myPlayer" data="" type="audio/mpeg" pluginspage="http://www.apple.com/quicktime/download" width="0" height="0">
    <param name="autoPlay" value="false" />
    <param name="controller" value="false" />
    <param name="enablejavascript" value="true" />
</object>

There is nothing in the data parameter because at render time, I don't know the URL that's going to be loaded. I set it like this:

var player = document.getElementById("myPlayer");
player.SetURL(url);

The audio will later be played back with:

player.Play();

Firefox 3.0.3 produces no error in the JavaScript console, but no playback occurs when Play() is called. Safari 3.0.4 produces the following error in the console:

"Value undefined (result of expression player.SetURL) is not object."

Internet Explorer 7.0.5730.11 gives the following extremely helpful error message:

"Unspecified error."

I have QuickTime version 7.4 installed on my machine. Apple's documentation says that SetURL() is correct, so why does it not work?

A: 

I don't know the QuickTime API, but this might be worth a shot:

player.attributes.getNamedItem('data').value = 'http://yoururlhere';
Kev
A: 

The page you linked to doesn't mention a 'data' attribute. They have an EMBED and PARAM within an OBJECT, with the EMBED's 'src' attribute having the url, but I don't see an EMBED in what you posted.

Kev
+1  A: 

Try giving the object element some width and height (1px by 1px) and make it visible within the viewport when you attempt to communicate with the plugin via JavaScript.

I've noticed that if the plugin area is not visible on screen it's unresponsive to JS commands.

This might explain why this isn't working for you in IE.

Safari and Opera should work, but FireFox will definitely require the Netscape style embed element, and really you should provide both. Additionally, once you have both, you need to ascertain which element (the object versus the embed) to address in which browser.

mczepiel