Preflighting a QTJ Installation

Given the hassle of setting up your own box with a custom QuickTime installation, the idea of having to walk your Windows users through such a process is probably unappealing. Installing the various QuickTime .dlls and such by yourself is not an alternative, because you promised not to redistribute QuickTime when you clicked “agree” on that license.

Tip

You know the license I mean—it’s the one you didn’t read! That’s OK, I didn’t read it either.

Fortunately, QuickTime 6 offers a “preflighting” feature that allows you to create an XML file that describes what QuickTime features you need, open the file with QuickTime, and have QuickTime download and install your features if they’re absent.

How do I do that?

In your favorite text editor, create an XML file, as seen in Example 1-2.

Example 1-2. Preflighting to install QTJ

<?xml version="1.0"?>
<?quicktime type="application/x-qtpreflight"?>
<qtpreflight>
  <component type="null" subtype="qtj "/>
</qtpreflight>

Save this file with a .mov extension to associate it with QuickTime.

Have QuickTime open this file in whatever means is appropriate for your application—embed it in a web page, have an installer script open it with QuickTimePlayer.exe, etc. When you do, QuickTime will check to see if QuickTime for Java has been installed; if QTJ hasn’t been installed, this will give the user a chance to download and install it, as seen in Figure 1-5.

Installing QuickTime for Java via preflighting

Figure 1-5. Installing QuickTime for Java via preflighting

What just happened?

The XML file specifies a list of QuickTime components that the application knows it needs to run. These components are classified in a type/subtype scheme. For example, to test for MPEG-4 support, you’d use type "imdc" (short for image decompressor) and subtype "mp4v“. QuickTime for Java is something of a special case, so it gets type "null" and subtype "qtj“. The trailing space on the subtype is really important, because all types and subtypes must be exactly four characters long.

Note

Chapter 4 has much more information about components and the FOUR_CHAR_CODES that identify them.

If any of the specified components are found to be absent, QuickTime brings up a dialog and offers the user a chance to download and install them on the spot.

Tip

Because the XML file is pretending to be a movie, QuickTime Player will open it up with a typical movie window, which will hang around whether or not the install is approved and succeeds. Apple recommends embedding the preflight movie in an HTML page and using the width and height parameters of the <embed> tag to give it an unobtrusive size of 2 pixels by 2 pixels, so the user probably won’t even see it.

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.