Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

JavaScript Support for ActiveX, Netscape 6 and Mozilla

New in QuickTime 6, the QuickTime ActiveX control for Windows is fully scriptable using JavaScript.

This means you can now use JavaScript to control QuickTime when Web pages are viewed using Internet Explorer for Windows, or any other browser that supports the COM interface to ActiveX controls.

Also new in QuickTime 6, the QuickTime browser plug-in is scriptable using the XPCOM interface supported by Netscape 6 and later and Mozilla 1.0.

This means you can now use JavaScript to control QuickTime when Web pages are viewed using Netscape 6 or later, or browsers based on Mozilla 1.0, on both Mac OS and Windows.

QuickTime is now scriptable from Web pages viewed using any browser that supports JavaScript and any of the LiveConnect, XPCOM, or COM interfaces. This includes most current browsers for Windows and Macintosh, with the notable exception of Internet Explorer for Macintosh, which does not allow scripting of plug-ins.

Note: The QuickTime browser plug-in has been scriptable using the LiveConnect interface since QuickTime 4.1, as documented in “What's New in QuickTime 4.1,” available at <http://developer.apple.com/techpubs/quicktime/qtdevdocs/REF/QT41_HTML/QT41WhatsNew-72.html>. This allowed scripting by Netscape 4 and 5 on both Mac OS and Windows.

In summary:

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 there).

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. 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.

An example of usage and syntax, showing JavaScript control of multiple QuickTime movies using different methods of addressing, can be found in the “Sample JavaScript Usage” section of “What’s New in QuickTime 4.1” at:

http://developer.apple.com/documentation/quicktime/REF/QT41_HTML/QT41WhatsNew-80.html

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.

Detailed descriptions of the QuickTime methods and properties available to JavaScript can be found in the “JavaScript Support” section of “What’s New in QuickTime 4.1” at:

http://developer.apple.com/documentation/quicktime/REF/QT41_HTML/QT41WhatsNew-72.html

Note: A bug in the current version of Netscape 6 for Mac OS X causes it not to see the QuickTime plug-in unless a file is copied from the OS X Internet Plugins folder to the Netscape 6 components folder. The file is "nsIQTScriptablePlugin.xpt" and the NS6 components folder is usually: /Applications/Mozilla1.0/Mozilla1.0.app/Contents/MacOS/Components/ After the file is copied, Netscape 6 must be told to refresh its components list. This can be done either by deleting the xpti.dat file and restarting Netscape, or by issuing the JavaScript command: navigator.plugins.refresh().

This bug is marked as fixed for the next release of Netscape and Mozilla.



< Previous PageNext Page > Hide TOC


Last updated: 2002-07-01




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice