views:

14

answers:

0

I'm attempting to control a QuickTime object that I have embedded into a webpage using JavaScript, and want to listen to and react to the DOM events that the object throws. Apple has published a tutorial on the matter that doesn't seem to work at all. The code that I made using their documentation is as follows:

$(document).ready( function() {
     $('#plugin').html( QT_GenerateOBJECTText( 'http://streaming1.wecreate.com:443/ckkw_kfun.mp3' , '300', '300', '', 'obj#ID', 'qt', 'emb#ID', 'qt', 'emb#NAME', 'qt', 'postdomevents', 'true', 'EnableJavaScript', 'true', 'autoplay', 'true' ) );
    qt = document.getElementById('qt');
    if(!qt ) {
        alert("Couldn't get QT Handle");
     }
     RegisterListeners();
});

function myAddListener(obj, evt, handler, captures) {
     if ( document.addEventListener )
          obj.addEventListener(evt, handler, captures);
     else
          obj.attachEvent('on' + evt, handler);
}
function RegisterListener(eventName, objID, embedID, listenerFcn) {
     var obj = document.getElementById(objID);
     if(!obj )
          obj = document.getElementById(embedID);
     if(obj)
          myAddListener(obj, eventName, listenerFcn, false);
}
function RegisterListeners() {
     RegisterListener('qt_begin', 'qt', 'qt', qtStateChanged);
     RegisterListener('qt_play', 'qt', 'qt', qtStateChanged);
     RegisterListener('qt_pause', 'qt', 'qt', qtStateChanged);
}
function qtStateChanged() {
    alert("State Changed!");
}

That code isn't as clean as it could be - I should be carrying the qt object through it all, but I wanted to leave it as close to Apple's demo code as possible.

In firefox, the code successfully loads the QuickTime object and begins playing the stream (as per the autoplay option), but I don't receive a single call to qtStateChanged() even though I have set the postdomevents and enablejavascript parameters set on the QuickTime object.

In Chrome, I get the QuickTime logo, but no audio or controls. The object reports the qt_begin event, and I get a JavaScript alert. In IE6 (we still have some technologically backward customers), the player loads, but the autoplay option doesnt work, and the JavaScript callbacks don't work at all.

I've also tried to control the player from JavaScript, again to no avail. The following are three different jQuery statements that attempt to pause the player. None of them work in any of the three browsers that I've tested in:

<p onclick="JavaScript:$(qt).Pause();">Suck it, Trebek</p>
<p onclick="JavaScript:$('#qt').Pause();">Suck it again, Trebek</p>
<p onclick="JavaScript:$('#plugin').Pause();">Suck it a third, Trebek</p>   

Does anybody have any insight on this communication between JavaScript and QuickTime? A tutorial that wasn't written 10 years ago would be a great boon.

Thanks.