How to fire a Javascript function when a QuickTime movie has finished playing?
When a Quicktime movie has ended, I want to replace it with a image slideshow. My current approach is to have the .mov file communicate back to the Javascript on the page. Once the end of the movie is reached, an event calls a function.
So my question is: What method can I use to call a Javascript function when a Quicktime movie ends?
I see some ideas here, but it is difficult to put the pieces together. http://developer.apple.com/mac/library/DOCUMENTATION/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//apple_ref/doc/uid/TP40001526-CH001-SW5
I am hoping to use the qt_ended()
function.
Here is my code so far:
<object width="853" height="496" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="enablejava开发者_Go百科script" value="true" />
<param name="postdomevents" value="true" />
<param name="src" value="/wp-content/themes/gono9/videos/General_Orders_No9_Trailer1.mov" />
<param name="controller" value="true" />
<param name="autoplay" value="true" />
<param name="scale" value="aspect" />
<param name="bgcolor" value="000000" />
<param name="cache" value="true" />
<embed width="853" height="496" src="/wp-content/themes/gono9/videos/General_Orders_No9_Trailer1.mov" bgcolor="000000" cache="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" controller="true" enablejavascript="true" postdomevents="true" autoplay="true" scale="aspect"></embed>
</object>
Does qt_ended()
go in my .js file?
I need help putting the pieces together.
If looking at the existing website helps: http://generalordersno9.com
This is related to the trailer.I answered my own question by reading the Apple documentation.
For those interested the code is here:
http://www.generalordersno9.com/wp-content/themes/gono9/js/g.js
And the demo is here: http://www.generalordersno9.com/
qt_ended
isnt necessaily the function name. thats the event name it fires. You have to add the function as a callback to the event. Ive never messed with QT via js but using jquery it would look something like this:
var myQuickTime = {
ended : function() {
// save a reference to the movie object
var movie = this;
// do stuff when the movie has ended
alert('Movie "#'+$(movie).attr('id')+'" Done!');
}
};
$(function(){
// add the listener on dom ready
$('#mymovie').bind('qt_ended', myQickTime.ended);
});
Now im not 100% on using jQuery's bind
method. It may be for some reason that you have to use baseline js as shown in the examples on the link you posted (see the myAddListener function). I wouldnt think this is the case because this is part of what jQuery's bind
method does, but you never know :-)
IIRC, Apple's javaScript interface for QuickTime is broken, and has been for years. There is no indication that they will fix it. You're supposed to use HTML5 video (which has a proper, functional 'ended' event that works).
If you are lucky, your QT movie is already using H264 or some other MPEG-4 codec, in which case, it might just work with the HTML5 video tag, although you might need to save as.. or export with a m4v extension first.
精彩评论