Inside Macintosh: QuickTime Reference
| Previous | Chapter Contents | Chapter Top | Next |
The QuickTime plug-in now supports JavaScript, allowing you to query and control QuickTime movies in a Web page.
QuickTime 4.1 is scriptable by browsers that support the LiveConnect interface between JavaScript and plug-ins. This includes Netscape 4.x and 5.x on both Windows and Macintosh. It does not include Internet Explorer on either Windows or Macintosh.
QuickTime 6 and later is scriptable using either the LiveConnect or XPCOM interface, and the QuickTime 6 ActiveX control for Windows is scriptable using the COM interface. This makes QuickTime 6 scriptable in Netscape 6 and other Mozilla-based browsers that use the XPCOM interface, as well as Internet Explorer for Windows, which uses the COM interface.
Internet Explorer for Macintosh does not currently support any interface allowing JavaScript to access a plug-in's methods.
To summarize
To control a movie through the QuickTime plug-in using JavaScript, you must include the parameter EnableJavaSript="true" in the movie's EMBED tag (this parameter is not needed in the OBJECT tag, but it does no harm).
Note:
You cannot query or control QuickTime from JavaScript until the browser
loads an instance of the plug-in. For example, you can write a movie's
EMBED tag using JavaScript, but you cannot use JavaScript to check the
QuickTime version before writing the tag. For this kind of interaction,
you must run the JavaScript from a page that already has an embedded
movie loaded; you can then write tags to other documents based on
QuickTime properties.
JavaScript treats each embedded QuickTime movie in a Web page as a separately addressable object. Movies can be identified by name if there is a NAME parameter in the movie's EMBED tag and an ID attribute in the movie's OBJECT tag. Internet Explorer for Windows uses the ID attribute. All other browsers use the NAME parameter. Both NAME and ID should be set to the same value.
For example, to create a movie that can be addressed in JavaScript as "Movie1", your OBJECT and EMBED tags would look something like this:
<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab"
width="180" height="160"
id="movie1" >
<PARAM name="src" value="My.mov">
<EMBED width="180" height="160"
src="My.mov"
name="movie1"
enablejavascript="true">
</EMBED>
</OBJECT>
Movies can also be identified by their ordinal number in the JavaScript embeds[] array.
For an example of usage and syntax, showing JavaScript control of multiple QuickTime movies using both methods of identification, see Listing 6, "Sample JavaScript Usage".
QuickTime exposes dozens of methods to JavaScript, allowing you to control not only the standard user interface actions, such as playing and stopping a movie, but also more complex actions, such as layering and compositing. You can use JavaScript, for example, to enable and disable alternate audio, text, or video tracks, or change a video track's graphics mode or a sprite's current image.
The following pages describe the QuickTime methods and properties available to JavaScript.
Inside Macintosh: QuickTime Reference
| Previous | Chapter Contents | Chapter Top | Next |