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

< Previous PageNext Page > Hide TOC

Using SMIL in QuickTime

SMIL presentations may be used to enhance QuickTime playback. You can create standard SMIL documents and play them from the desktop or in a browser as if they were QuickTime movies. There are also QuickTime-specific extensions to SMIL that you can use to enhance your presentations.

In this section:

Creating QuickTime-Friendly SMIL Documents
Examples
Special Media Types
QuickTime SMIL Extensions
New SMIL Extensions Added in QuickTime


Creating QuickTime-Friendly SMIL Documents

For QuickTime to play a SMIL presentation, the presentation must be made up of media elements that QuickTime can play individually. This includes QuickTime movies, real-time streams in QuickTime format, AIFF and MP3 sound files, JPEG and GIF images, FLIC animations, text files, and MIDI music files.

If you can use a URL in the QTSRC parameter of an <EMBED> tag, and the QuickTime plug-in can play it successfully, you can use that URL as a media element in a SMIL document for QuickTime.

QuickTime doesn’t currently support the whole SMIL specification. You can use all the SMIL tags and parameters described in the tutorial, but if you’re working from the W3C specification, note the following exceptions:

Examples

A common use of SMIL is to specify an advertisement that should play when the viewer requests a live stream. The following is a simple SMIL document that does just that. It defines a display area and a background color, then specifies two display regions—one for the ad and one for the live stream. It plays an ad—a QuickTime movie from a CD—that includes a click-through link to www.apple.com. When the ad is done, the SMIL document opens a live stream, in this case the BBC world news.

<smil>
    <head>
    <layout>
    <root-layout id="rl" width="320" height="240"
        background-color="red"/>
 
    <region id="ad" width="200" height="240" left="60" top="0" />
    <region id="bbc" width="100%" height="100%" fit="fill" />
    </layout>
    </head>
 
    <body>
    <seq>
        <!-- ad -->
        <a href="http://www.apple.com"show="new"> <!-- opens a new browser                                         window if the ad is clicked on -->
            <video src="sample.mov" region="ad"/>
        </a>
        <!-- live stream -->
        <video src="rtsp://a628.q.kamai.net/7/628/52/935780134/
            qtv.akamai.com/bbc/bbc100" region="bbc" />
    </seq>
    </body>
</smil>

Note that the ad is centered by specifying a top and left offset for the ad region. Note also that you must specify both top and left as a pair, even though the top offset is 0. The live stream’s region is set to 100% of the available display area, and the stream’s visual area is scaled up to fill the region by specifying fit="fill".

As another example, here’s a way to create a narrated slide show using SMIL:

  1. Step through your slides using any tool, such as PowerPoint, JPEGView, or QuickTime Player (Present Movie—Slide Show mode).

  2. Record a narration as you go, using recording software or recording to tape and capturing to disk later.

  3. Open your narration in QuickTime Player, choose Get Info, and display the movie time as you listen to your narration.

  4. Write down the appropriate time to begin displaying each slide.

  5. Write a SMIL document similar to the one below, substituting the URLs of your slides and narration, and changing the slide durations as appropriate.

    <smil>
        <head>
        <layout>
            <root-layout id="rl" width="320" height="240"
                background-color="black" />
     
            <region id="slides" width="320" height="240" />
        </layout>
        </head>
     
        <body>
        <par>
        <audio src="narration.aif" />
        <seq>
            <img src="slide1.jpg" region="slides" dur="5S" />
            <img src="slide2.jpg" region="slides" dur="15S" />
            <img src="slide3.jpg" region="slides" dur="10S" />
        </seq>
        </par>
        </body>
    </smil>

This creates a slide show that starts the audio narration and the first slide in parallel, then displays the slides in sequence, giving each slide the specified duration.

Special Media Types

Text files, QuickTime VR panoramas and object movies, and HTML pages can all be specified as media elements in SMIL documents for QuickTime, but they deserve special mention.

Text

You normally specify a text file as a media element using the <text> tag: <text src="http://my.server.com/some.txt" region="r1" dur="5" />

Other SMIL players may present the whole text file as a block of text. QuickTime displays the text as it would any text file imported into QuickTime Player. You can see how the text will be displayed by importing it into QuickTime Player using the default import settings.

To modify the way the text is presented, import the text into QuickTime Player using any settings you like, export it as Text with Descriptors, and edit the descriptors in the exported file as needed. You can also generate a text file that includes QuickTime text descriptor tags using a CGI script or other software.

You can use a text file with QuickTime text descriptors as a SMIL media element when playing the SMIL file with QuickTime. All the descriptors are supported, including scrolling, keyed text, and hyperlinks.

SMIL considers text as not having an inherent duration, but importing a text file into QuickTime creates a movie with a duration of 2 seconds for each paragraph of text.

If you specify a duration for a text element that’s less than the duration of the text movie that Quicktime creates, the display of the text movie is truncated.

You can get around this by specifying the text file using the <video> tag: <video src="http://www.server.com/some.txt" region="aregion" />

This causes the text to be displayed for the duration of the text movie that QuickTime creates.

VR

Specify a QuickTime VR panorama or object movie using the <video> tag:

<video src="http://www.myserver.com/vr.mov" region="aregion" />

You can use VR panoramas and object movies, including multinode panoramas, and VR movies that have been enhanced using wired sprites.

However, VR movies inside SMIL presentations don’t have a VR controller attached. Viewers can navigate the VR movie using the mouse to drag left, right, up, and down, and to click from node to node, but they can’t zoom in or zoom out. You can add zoom controls by adding a wired sprite controller to the VR movie.

HTML

You can’t display HTML pages inside QuickTime Player or the QuickTime plug-in. It’s possible to use SMIL to display media from a Web page in QuickTime Player or the QuickTime plug-in, however. This capability is currently very limited, but it may be sufficient for your needs.

Suppose you want QuickTime to display an animated GIF, for example, but you don’t have a URL for the GIF itself, just the URL of a Web page that uses the GIF as a banner ad.

Note: This is fairly common if you have a script that generates Web pages and inserts banner ads according to an algorithm, and you want to take advantage of this script to put the same ad in a SMIL presentation.

Use the SMIL <image> tag to set up the presentation for the GIF, but use the URL of the Web page that contains the GIF in the SRC parameter. For this to work, you need to explicitly set the MIME type to HTML in the element tag: type="text/x-html-insertion"

The SMIL element looks like this:

<image src="http://www.myserver.com/index.html"
        type="text/x-html-insertion" region="aregion" dur="time" />

QuickTime opens the HTML document specified in the URL and scan it for a playable media element specified by a SRC parameter. QuickTime follows a particular logic in scanning a document for a playable element:

QuickTime takes the first source that it finds using this logic and attempts to use it as the media element specified in the SMIL document. For this to work, the first source QuickTime finds needs to match the specified element type, such as audio, video, or image.

Here’s an example of a Web page with a banner ad, and a SMIL document that uses the banner ad from the Web page as a clickable link over a streaming movie:

<HTML>
    <HEAD><TITLE>Welcome to XYZ Corp</TITLE></HEAD>
 
    <BODY>
        <A HREF="sponsor.htm"><IMG SRC="adbanner.gif"></A>
        ...
    </BODY>
</HTML>
<smil>
    <head>
        <layout>
            <root-layout height="290" width="512"
                background-color="black" />
            <region id="ad" height="50" width="512" />
            <region id="movie" height="240" width="320"
                top="50" left="98" />
        </layout>
    </head>
 
    <body>
        <par>
        <a href="sponsor.htm" show="new">
            <image src="welcometoxyz.html"
                type="text/x-html-insertion"
                region="ad" end="id(x)(end)" />
        </a>
        <video src="rtsp://server/stream.mov"
            region="movie" id="x" />
        </par>
    </body>
</smil>

QuickTime SMIL Extensions

SMIL is an extensible standard, and QuickTime provides several SMIL extensions. This allows you to add QuickTime-specific attributes to your SMIL presentation, such as autoplay="true".

To use QuickTime extensions in your SMIL document, include the xmlns: parameter and the URL of the QuickTime extensions as part of the initial <smil> tag:

<smil
xmlns:qt="http://www.apple.com/quicktime/resources/smilextensions">

QuickTime doesn’t actually access the URL; it’s used only to uniquely identify the QuickTime SMIL extensions.

You can include QuickTime extensions within the <smil> tag along with the URL. For example, to create a SMIL presentation that starts automatically:

<smil
xmlns:qt="http://www.apple.com/quicktime/resources/smilextensions"
qt:autoplay="true">

In the examples that follow, the xmlns: parameter and the URL have been omitted for readability, but they are a required part of the <smil> tag when any QuickTime extensions are used in a SMIL presentation. These are the current QuickTime SMIL extensions:

Example: <smil qt:autoplay="true">

Example: <smil qt:next="nextpresentation.smi">

Example: <smil qt:time-slider="true">

Note: If you want to import a SMIL presentation into QuickTime and edit it using QuickTime Player’s editing features—to add a chapter list for example—you must set time-slider="true". QuickTime Player’s editing features rely on the Time slider.

Example: <smil qt:immediate-instantiation="true">

Example: <imgsrc="bgimg.png"qt:immediate-instantiation="true"/>

Example: <imgsrc="test.png"qt:composite-mode="alpha" />

Example: <videosrc="stream56k.mov"qt:bitrate="56000" />

Important: Don’t confuse qt:bitrate with system-bitrate. Use system-bitrate to select a media element based on the user’s connection speed. Use qt:bitrate to help QuickTime determine when to start downloading a media element.

Example:

<switch>
 
<imgsrc="qt.mov"
        qt:system-mime-type-supported="video/quicktime"/>
 
<imgsrc="someotherformat.suffix"
qt:system-mime-type-supported= "other/mime-type"/>
 
</switch>

Example: <smil qt:chapter-mode="clip"/>

Example:

<videosrc="some.mov"qt:chapter="chap1" region="r1" />
...
<a href="#chap1" show="replace" >
<img src="BackToChap1.gif" region="r2" dur="5:00" />
</a>

In the example above, clicking in region r2 while BackToChap1.gif is displayed rewinds the presentation to chap1, causing some.mov to restart.

Example:

<ahref="http://www.server.com/another.smi"show="new"
qt:target="quicktimeplayer">
<img src="OpenNewSMIL.gif" region="r2" dur="5:00" />
</a>

New SMIL Extensions Added in QuickTime

The current release of QuickTime includes the addition of several new SMIL extensions.

The SMIL extension, "qt:preroll", accepts an integer representing the number of seconds to open and prepare to play an embedded movie. The attribute can be added to any media object; the default remains 15 seconds.

The begin-clip and end-clip attributes are now supported for media elements.

Another SMIL extension allows fullscreen playback by adding "qt:fullscreen" to the SMIL element. "qt:fullscreen" can be set in the SMIL header; it accepts one of the following attributes:

qt:fullscreen="fullscreen_false"
qt:fullscreen="fullscreen_normal"
qt:fullscreen="fullscreen_double"
qt:fullscreen="fullscreen_half"
qt:fullscreen="fullscreen_full"
qt:fullscreen="fullscreen_current"

Relative URLs work with qtnext user data and with the "qt:next" attribute of SMIL documents. Therefore, the following works:

<smil xmlns:qt="http://www.mywebsite.com/quicktime/resources/smilextensions" qt:next="in_the_same_directory_as_this_document.mov"> . . . </smil>



< Previous PageNext Page > Hide TOC


Last updated: 2002-10-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