QuickTime Developer Series

Sample Chapter


| Next | Prev | Top |

Some Particularly Cool Features

Autoplay

As John Brunner once wrote, "It's supposed to be automatic, but actually you have to push this button." You can simplify the user interface by having the QuickTime movie start playing automatically. The user doesn't have to do anything. People are singularly amazed when they click into a website and it just starts talking.

AUTOPLAY="True" | "False" (the default is "False" )

    Example

    <EMBED SRC="My.mov" HEIGHT="256" WIDTH="320"
    AUTOPLAY="True">

Your viewers can set their own default value for autoplay using their QuickTime settings, so set this to False if you want to be 100% certain that the movie won't start until the user clicks a button.

A new feature of autoplay for QuickTime 5 is the ability to start a movie playing when the network download has reached a certain point in the movie. Normally, QuickTime will start the movie when it calculates that it has downloaded enough to play the whole movie without interruption (the remaining data will arrive by the time it's needed). If the data transfer rate slows, QuickTime may have to pause during playback while more of the file downloads. This can cause "false starts" or stuttering. You can prevent most problems of this sort by setting the movie to autoplay after a few seconds have downloaded, rather than right away. The syntax is

AUTOPLAY="@HH:MM:SS:FF"

where HH = hours, MM = minutes, SS = seconds, and FF = 30ths of a second.

Hide the Controller

Hiding the controller is normally a bad idea because the user can't stop or rewind the movie--if you haven't set AUTOPLAY="True" , they can't even start the movie. But for a background sound, a hidden controller can be just the ticket. For background sound, you normally combine QuickTime's CONTROLLER and AUTOPLAY parameters with the browser's HIDDEN parameter.

CONTROLLER="True" | "False" (default is "True" except for .swf files)

    Example

    <EMBED SRC="Sound.mov" HEIGHT="2" WIDTH="2"
    AUTOPLAY="True" HIDDEN="True" CONTROLLER="False">

Audio Volume

By default, the QuickTime plug-in plays audio at full volume, which is 100% of the loudness the user has selected in the computer's Sound control panel. You can use the VOLUME parameter to create quiet background music or barely perceptible whispering. Note that MIDI at full volume is generally louder than recorded sound, so setting the volume to 75% is a good way to play MIDI sounds at the expected level.

VOLUME=" Percent " (0-300)

    Example

    <EMBED SRC="MyMIDI.mov" HEIGHT="16" WIDTH="180"
    AUTOPLAY="True" VOLUME="75">

Values of greater than 100 can be used to overdrive the audio. This should be done cautiously because it can create distortion and clipping, not to mention annoyance.

    Tip  If you choose to include looping background music on your site, set a low volume. That way, fewer people will want to strangle you.

Play Something Else, Man

You can tell the QuickTime plug-in to play a different file than the one specified by the SRC parameter of the <EMBED> tag. This is crucial because the browser uses the SRC parameter to decide which plug-in to use. If the SRC parameter specifies a QuickTime image ( .qti ) or a MacPaint image ( .pntg ), the browser will choose the QuickTime plug-in. You can then use the QTSRC parameter to tell the plug-in to play a QuickTime movie, Flash ( .swf ), MIDI, MP3, or other file type. This is discussed in more detail in See Bust a .Mov and See Basic Training: Putting QuickTime in a Web Page

QTSRC=" Filename "

    Example

    <EMBED SRC="UNeedQT4.qti" TYPE="image/x-quicktime" HEIGHT="16" WIDTH="180" QTSRC="Hot.mp3">

Set QTSRC to the name of the file you really want the plug-in to play. You can include a relative path or the full URL.

    Important  If you use a relative path, make it relative to the file specified in the SRC parameter, not relative to the HTML page.

Another important feature of the QTSRC parameter is that the QuickTime plug-in can get the specified URL using its own HTTP, RTSP, or file handling processes. This means that it works properly with RTSP URLs used for streaming movies and with local files that the browser itself might mishandle. It also means you can set a maximum download speed with the QTSRCCHOKESPEED parameter, described next.

The browser still downloads the file indicated by the SRC parameter, even though the plug-in ignores it. This is basically wasted bandwidth, so specify a small throw-away image in the SRC parameter. A good choice is UNeedQT5.qti , which you can find in the Basic folder of the CD. By the way, the SRC parameter has to point to a real file, or the browser gets confused.

Slow Down!

Okay, normally you want the movie to download faster, not slower. But a large movie can bring your server to its knees when someone downloads it using a T1 connection, even though 20 people could watch the same movie simultaneously using 56K modems. That's because the viewer with the T1 connection is using 1.5 megabits per second of bandwidth, the same as twenty-four 56K modems.

So if a movie has a data rate of less than 56,000 bits per second, for example, you want to limit the download speed to 56K--people can still watch the movie as it downloads, but someone with a fast Internet connection won't hog all your server's bandwidth.

You limit the bandwidth for a movie by setting its choke speed. The parameter is QTSRCCHOKESPEED . It applies only to movies specified by the QTSRC parameter, as described in Play Something Else, Man.

QTSRCCHOKESPEED = "MaxSpeed" (in bits per second)

    Example

    <EMBED SRC="UNeedQT4.qti" TYPE="image/x-quicktime" HEIGHT="16" WIDTH="180" QTSRC="Hot.mp3"
    QTSRCCHOKESPEED="130000">

Use a choke speed setting a little higher than the data rate of the movie to allow for network overhead. For a 128 Kbits/sec MP3, for example, set the choke speed to 130000 so people with fast connections can hear it in real time, but people with really fast connections won't use up all your Web server's bandwidth.

You can also set QTSRCCHOKESPEED="movierate" and QuickTime will do its best to use only as much bandwidth as needed to play the movie smoothly.

You also want to set the choke speed when delivering movies that mix streaming and nonstreaming tracks, so you can reserve some bandwidth for the streaming parts. For details, see Mixing It Up: Streaming and Nonstreaming

    Tip  As of this writing (QuickTime 5.02), QTSRCCHOKESPEED limits only the download speed of the actual movie file specified by QTSRC . Any data contained in external files, including alternate data rate movies, is unaffected. For now, use QTSRCCHOKESPEED with self-contained movies.

Click Here, Play There (Poster Movies)

You can associate a URL with a QuickTime movie, so the URL loads when someone clicks inside the movie's display area. This lets you do a number of interesting things. The URL can specify a Web page, a JavaScript function, or a second movie. If the URL specifies a Web page, that page can include an embedded movie of its own.

You can specify a target for the URL, so it loads in another frame or another window. You can also target the URL to replace the current movie in the QuickTime plug-in, or to load in the QuickTime Player application, launching it if necessary.

This last feature is particularly useful. You can embed a movie for the plug-in, typically a single image with no controller, and tell the plug-in to launch a different movie in QuickTime Player when someone clicks the image. An example of this is Poster2.htm (in the SpecialDelivery folder on the CD), shown in the following illustration.

HREF= "url" TARGET="FrameName" TARGETCACHE="True" | "False"

    Example

    <EMBED SRC="Poster.mov" HEIGHT="256" WIDTH="320"
    CONTROLLER="False" HREF="Actual.mov"
    TARGET="quicktimeplayer">

     

The TARGET parameter is optional. It works just like the TARGET parameter in an <A HREF> tag; it can specify a frame or a window, and it can be used to create a new window with a given name. It also supports three special values:

  •   myself --causes the URL to replace the current movie in the plug-in
  •   quicktimeplayer --loads the URL in the player application
  •   browser --loads the URL in the default browser window, even if the movie is playing in QuickTime Player

Important  The special values are case-sensitive in some versions of QuickTime, so use all lowercase.

If you set TARGET="myself" , the image is transformed into a movie when the user clicks it.

You can also use the HREF parameter to trigger a JavaScript function and pass data to it when someone clicks the movie:

<EMBED SRC="ClickMe.mov" HEIGHT="256" WIDTH="320"
HREF="javascript:openMovie('HugeMovie1.htm')">

    Note  A bug in Explorer 4.5 caused it to ignore HREF parameters that began with
    javascript: , but this is fixed in subsequent versions.

If you want the URL specified in the HREF parameter to load automatically, instead of waiting for a mouse click, include the AUTOHREF="True" parameter. (The AUTOHREF parameter requires QuickTime 4.1 or later.)

<EMBED SRC="UNeedQT4.qti" TYPE="image/x-quicktime"
HEIGHT="2" WIDTH="2" HIDDEN="True"
HREF="Actual.mov" TARGET="quicktimeplayer" AUTOHREF="True" >

    Important  If you use a relative URL in the HREF parameter, it must be relative to the poster movie , not relative to the current Web page.

To learn more about making poster movies, see Making a Poster Movie. To learn more about using poster movies to launch QuickTime Player, see Launching QuickTime Player from a Poster Movie. To see how to use poster movies to embed multiple movies on a Web page, see Poster Movies.

Start and End Times

You can tell the plug-in to play just part of a movie by setting the start time, the end time, or both. You might do this to create a series of buttons, each of which plays a different clip from the same movie. This technique is most useful with streaming movies or local movies.

STARTTIME="StartTime" ENDTIME="EndTime"

    Example

    <EMBED SRC="Long.mov" HEIGHT="176" WIDTH="120"
    STARTTIME="00:01:10:0" ENDTIME="00:02:10:0"
    AUTOPLAY="True">

Times are in Hours:Minutes:Seconds:Fractions relative to the start of the movie ( 00:00:00:0 ). The fractions are expressed in 1/30ths of a second. For 30 frames-per-second video, each fractional time unit is one frame. The example above plays one minute of Long.mov , starting one minute and ten seconds into the movie. You can specify just a start time or just an end time.

    Important  The timecode is expressed as HH:MM:SS:FF , not HH:MM:SS.FF (the separator is a colon, not a decimal point). This is different from the timecode displayed by QuickTime Player's Info window, which uses the decimal point.

You normally want to set AUTOPLAY="True" when you specify a start or end time, so the clip just plays; otherwise the user might try to position the controller to play a different clip. When you specify a start or end time, the viewer cannot play any earlier or later part of the movie.

    Note  Setting start and end times for a clip is useful for real-time streaming movies or local movies on a disk--it's less useful for Fast Start movies over the Internet because the whole movie downloads, not just the specified clip.

Play a Series of Movies

You can tell the QuickTime plug-in to play a series of movies, one after the other. When the current movie finishes, the next movie in the list starts. This can be a good way to deliver a long movie; users never need to store more than a small piece of it on their computers at any time.

QTNEXT n ="< Filename > T< Target >" or "GOTOn"

    Example

    <EMBED SRC="First.mov" HEIGHT="176" WIDTH="120"
    QTNEXT1="<Second.mov> T<myself>"
    QTNEXT2="<Third.mov> T<myself>">

You have to append a number between 1 and 255 to each QTNEXT . They execute in numerical order.

Note that you must place angle brackets around the < Filename > and T< Target > values, and quotes must surround both values jointly:

"< Filename > T< Target >"

Set < Filename > to the name of the file you want to play next. You can include a relative path or the full URL.

The T< Target > parameter is optional. It specifies where the movie plays. If it's not specified, the next movie replaces the current browser window or frame, and any subsequent QTNEXT statements are lost. The special value of T<myself> targets the QuickTime plug-in and is normally the value you want; the next movie replaces the current movie, and subsequent QTNEXT statements are executed in turn. The target can also be the name of a browser window or frame. If no window or frame of that name exists, a new browser window with that name is created. You can also specify T<quicktimeplayer> as a target, which opens the movie in QuickTime Player.

    Important  The special targets T<myself> and T<quicktimeplayer> are case-sensitive in some versions of QuickTime. Use all lowercase.

Each QTNEXT statement has an index number, which is the order in which the movies play. If you specify a QTNEXT1 , then a QTNEXT5 , and then a QTNEXT10 , for example, the three of them execute in numerical order, and their index numbers are 1, 5, and 10. Want to keep your sanity? Number the QTNEXT statements in simple numerical order: 1, 2, 3, . . . .

The special index value of 0 is assigned to the original movie named in the SRC parameter (or the QTSRC parameter, if it was specified).

Why have index numbers? Because instead of a filename, you can specify GOTO n , where n is the index of the QTNEXT you want to go to. You normally do this to create a simple loop:

<EMBED SRC="First.mov" HEIGHT="176" WIDTH="120"
QTNEXT1="<Second.mov> T<myself>"
QTNEXT2="<Third.mov> T<myself>"
QTNEXT3=GOTO0 >

This example plays First.mov , then Second.mov , then Third.mov , then goes back to First.mov (index 0), in an endless loop. You can use values other than 0 to cause QTNEXT statements to play in arbitrary order, or to start looping from some midpoint. For example,

<EMBED SRC="Intro.mov" HEIGHT="176" WIDTH="120"
QTNEXT1="<First.mov> T<myself>"
QTNEXT2="<Second.mov> T<myself>"
QTNEXT3=GOTO1 >

would play the Intro.mov just once, then play First.mov and
Second.mov in an endless loop.

    Important  If you use a relative URL in a QTNEXT parameter, it must be relative to the currently loaded movie, not relative to the current Web page. In a series of QTNEXT statements, each URL is relative to the previous movie.

    Note  A bug in QuickTime 4.1 caused GOTO0 to play the most recent movie instead of the first movie in the sequence, although any subsequent movies in the sequence played correctly. The workaround is to specify the original movie at the beginning and end of the loop, and use GOTO1 instead:

<EMBED SRC="First.mov" HEIGHT="176" WIDTH="120"
QTNEXT1="<Second.mov> T<myself>"
QTNEXT2="<Third.mov> T<myself>"
QTNEXT3="<First.mov> T<myself>"
QTNEXT3=GOTO1 >

This sequence plays correctly whether the bug is present or not.

Save It Right

The QuickTime plug-in has a couple of options that control how viewers can save movies, or not save them: KIOSKMODE and DONTFLATTENWHENSAVING .

You can provide basic copy protection for your movie by setting KIOSKMODE to True . The plug-in disables its Save As Source and Save As QuickTime Movie commands, and doesn't allow drag-and-drop saving to the desktop.

Of course, this isn't foolproof protection, but it will stop honest people and discourage opportunists. You can get stronger protection using Plug-in Helper, as described in Copy-Protecting Movies.

KIOSKMODE="True" | "False"

    Example

    <EMBED SRC="DontCopyMy.mov" HEIGHT="176" WIDTH="120"
    KIOSKMODE="True">

That's it for KIOSKMODE .

The DONTFLATTENWHENSAVING parameter is a little more complicated because you have to understand movie flattening. It's like this: movies can contain references that point to their media data; that data can be in an external file, or it can be data stored in the movie file itself. Movies can contain multiple references to a single chunk of data. When a movie is flattened, all the references are replaced with actual copies of the data. If the data is copied from external files into the movie file, this makes the movie self-contained. If the references are to data already inside the movie file, flattening replaces internal references with internal copies. In either case, it makes the movie file larger.

Unless you've copy-protected a movie, your viewers can save a copy of your movie using the QuickTime plug-in. You can control whether or not the QuickTime plug-in saves a flattened copy of the movie. By default, the Save As Source command saves without flattening, and the Save As QuickTime Movie command saves and flattens.

Most movies on the Web are already flattened, so it doesn't matter which you choose. But it can make a very large difference otherwise.

If the movie on your Web server isn't self-contained, you can prevent people from making a working copy of the movie by setting the DONTFLATTENWHENSAVING parameter in the <EMBED> tag. If the viewer then saves the movie from a browser, data in external files isn't copied. The saved movie won't play unless those files are present on the user's computer (which they won't be).

If you've created a movie with a lot of internal references, you should set the DONTFLATTENWHENSAVING parameter for a different reason. If it isn't set, all the references will turn into copies when the movie is saved, resulting in a huge file. For example, let's say you've made a movie using a 60 Kbytes audio sample that's referenced two hundred times. With internal references, the file is a little over 60 Kbytes in size; flattened, it swells to 12 MB. So tell the plug-in DONTFLATTENWHENSAVING .

DONTFLATTENWHENSAVING

    Example

    <EMBED SRC="DontCopyMy.mov" HEIGHT="176" WIDTH="120"
    DONTFLATTENWHENSAVING>

Background Color

The browser allots space on your Web page for the QuickTime plug-in in response to the HEIGHT and WIDTH parameters. If you allot exactly enough space for the movie, the background doesn't show through, so its color doesn't matter.

But if you're showing a movie that plays at different sizes for different speed connections, or you're playing a series of movies that are different sizes, you need to allot enough space for the biggest movie. When a smaller movie is playing, the background shows. So set a background color that looks good on your Web page.

BGCOLOR= "# rrggbb " (or one of the named colors listed in the next section)

    Example

    <EMBED SRC="MultiSize.mov" HEIGHT="336" WIDTH="240"
    BGCOLOR="#0000FF">

The color is specified using a hexadecimal value made up of three 1-byte values: 1 byte each for red, green, and blue, with each value having a range of 00 to FF . This is identical to the way you specify the BGCOLOR parameter in the HTML <BODY> tag. Alternately, you can specify some colors by name, such as Black or Red . The named colors are listed in Summary of QuickTime Plug-in Parameters below.

Combined Operations

You can combine plug-in features in an almost unlimited number of ways. For example, let's say you want a movie to play in QuickTime Player without requiring the viewer to click a poster movie, and you'd like to precede the movie with a little fanfare of trumpets. You can do this by combining the HIDDEN , CONTROLLER , AUTOPLAY , and QTNEXT parameters.

    Example

    <EMBED SRC="Fanfare.mov" HEIGHT="2" WIDTH="2"
    HIDDEN="True" AUTOPLAY="True" CONTROLLER="False"
    QTNEXT1="<Player.mov> T<quicktimeplayer>" >

This causes Fanfare.mov to play automatically in the background when the HTML page loads in a browser. As soon as Fanfare.mov finishes, Player.mov loads in the QuickTime Player application, outside the browser.


| Next | Prev | Top |
Copyright 2002 by Academic Press


Home | Updates | Corrections | FAQ | Table of Contents | Sample Chapter