previous next

Chapter 7: SMIL Sequences

Chapter 6 explains the basics of SMIL, and shows how to open HTML pages when a single clip plays. This chapter builds on that foundation to show you how to play a sequence of clips using SMIL. It also introduces you to some of the SMIL timing attributes that you can use for clips and hyperlinks.

Playing Clips in Sequence

As "Writing a Ram File" explained, you can play a sequence of clips by listing the clips in order in a Ram file. If you want to use SMIL timing or linking with the clips, though, it's easier to define the sequence within a SMIL file. So instead of writing a separate SMIL file for each clip, you write one SMIL file that defines all of the features of the sequence. Your Ram file then links to the single SMIL file.

A sequence is the simplest type of SMIL group to create. Just list the clips within <seq> and </seq> tags in the order that you want them to play. The following example shows the entire SMIL markup required to play three audio clips in sequence:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">
<body>
<seq>
<audio src="rtsp://helixserver.example.com/song1.rm"/>
<audio src="rtsp://helixserver.example.com/song2.rm"/>
<audio src="rtsp://helixserver.example.com/song3.rm"/>
</seq>
</body>
</smil>

In the preceding example, the second clip begins when the first clip finishes, and the third clip begins when the second clip finishes. A sequence can include any number of clips, and the clips can be of any type. You could add a video clip to the sequence shown above, for example. When using visual clips, though, you need to define a layout. Chapter 8 tackles layouts in general, but the section "Laying Out a Sequence of Videos" offers a "universal layout" for any sequence of videos.

When you enclose clips in <seq> and </seq> tags, RealOne Player treats the sequence as a single presentation. If each clip in the preceding example is two minutes in length, for example, the RealOne Player status bar indicates that the presentation is six minutes long. Because RealOne Player treats the sequence as a single presentation, viewers can use the timeline slider to seek through all the clips, but cannot choose individual clips through the RealOne Player Play>Next Clip command.

View it now! (requirements for viewing this sample)
Play this sample to hear a sequence of three audio clips that uses a <seq> group. Each clip lasts 15 seconds. Note that RealOne Player indicates that the presentation lasts 45 seconds, and that you cannot use the Play>Next Clip command.

Creating Sequences Without the <seq> Tag

It is not necessary to use <seq> and </seq> tags to create a clip sequence. Whenever clips are not listed in a group, RealOne Player plays them in sequence. For instance, the following markup, which has no <seq> and </seq> tags, plays three audio clips in sequence just like the preceding example:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">
<body>
<audio src="rtsp://helixserver.example.com/song1.rm"/>
<audio src="rtsp://helixserver.example.com/song2.rm"/>
<audio src="rtsp://helixserver.example.com/song3.rm"/>
</body>
</smil>

When you do not use a <seq> group, however, RealOne Player treats each clip as a separate presentation. Suppose that each clip in the preceding example lasts two minutes. When the sequence starts, the RealOne Player status bar indicates that the presentation lasts two minutes. When the first clip ends, RealOne Player's timeline slider resets, the second clip starts, and the status bar indicates another two-minute presentation. This action repeats when the third clip plays. At any point, the viewer can select a different clip with the RealOne Player Play>Next Clip command.

View it now! (requirements for viewing this sample)
Play this sample to hear a sequence of three audio clips that does not use a <seq> group. Each clip lasts 15 seconds, and the timeline slider resets after each clip plays. You can also use the Play>Next Clip command.

Laying Out a Sequence of Videos

When you play a sequence of visual clips such as videos, you need to define a layout. Otherwise, RealOne Player displays the clips in a checkerboard pattern, which is rarely desirable. However, it's easy to create a simple layout that sets a size for the media playback pane, then centers each video in the pane. Chapter 8 explains layouts in detail, but the following sample defines a universal layout that works for most video sequences:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">
<head>
<layout>
<root-layout width="320" height="240"/>
<region id="video_region"/>
</layout>
</head>
<body>
<seq>
<video src="rtsp://helixserver.example.com/video1.rm" region="video_region"
regPoint="center" regAlign="center"/>
<video src="rtsp://helixserver.example.com/video2.rm" region="video_region"
regPoint="center" regAlign="center"/>
<video src="rtsp://helixserver.example.com/video3.rm" region="video_region"
regPoint="center" regAlign="center"/>
</seq>
</body>
</smil>

The preceding sample sets the size of the media playback pane to 320 pixels wide by 240 pixels high. It then creates one playback region that expands to that same size. Note that each clip includes region="video_region" to assign it to the playback region, which uses id="video_region". The regPoint="center" and regAlign="center" attributes place each clip in the center of the region. This layout thereby accommodates any clip up to 320-by-240 pixels, which is as large of a video that you can stream at high quality over low to moderate connection speeds.

View it now! (requirements for viewing this sample)
Play this sample to see three video clips play in sequence.

For More Information: For more on bit rates and video sizes, see "Video Dimensions".

Adding Clip or Group Information

The SMIL attributes listed in the following table let you override information encoded in a clip. They work like the Ram file parameters described in "Overriding Title, Author, and Copyright Information". When using these attributes in the SMIL file, however, do not also use the equivalent Ram file parameters.

Clip and Group Information Attributes
Attribute Value Function
author author_name Defines the author name.
copyright copyright_notice Provides a copyright notice.
title title_text Creates a title for the "Now Playing" list.

Each attribute takes a text string for its value:

<video src="rtsp://helixserver.example.com/video1.rm" 
title="
title" author="name" copyright="date"/>

When you leave the <seq> tag out, as described in "Creating Sequences Without the <seq> Tag", the individual clip titles display in the RealOne Player "Now Playing" list:

<body>
<audio title="This is Clip 1" .../>
<audio title="This is Clip 2" .../>
</body>

When you group clips within a <seq> or <par> tag, the clip titles are ignored. You should therefore add title, author, and copyright information to the group tag, as shown in the following example:

<seq title="This is Sequence 1">
<audio .../>
<audio .../>
</seq>

For More Information: For information about the <par> tag, see "Playing Clips in Parallel". The SMIL file can also define overall presentation information in addition to clip or group information, as described in "Presentation Information".

Using SMIL Timing Attributes

SMIL includes many timing attributes that you can use in clips or hyperlinks. The following sections describe the most commonly used attributes. The following table lists the values that you can use in SMIL timing attributes.

Timing Values and Examples
Timing Marker Specifies Example Example Value
h hours begin="2.5h" 2 hours, 30 minutes
min minutes begin="2.75min" 2 minutes, 45 seconds
s seconds begin="15.55s" 15 seconds, 550 milliseconds
ms milliseconds begin="670.2ms" 670.2 milliseconds

Note: Decimal values are not required. You can express two seconds as "2s" or "2.0s", for example.

Tip: RealOne Player displays a presentation's elapsed time in one-second increments. You can click the time-elapsed field to display time values to 1/10th of a second, however. This can help you decide what timing values to use with a clip.

For More Information: The endsync attribute, which affects timing in a parallel group, is described in the section "Ending a Parallel Group on a Specific Clip".

Setting a Begin Time

The section "Opening Several Web Pages During a Presentation" introduced you to the begin attribute, which creates a timing delay. Using the begin attribute, you can vary the point at which a hyperlink becomes active, or a clip starts to play back within the presentation timeline:

<video src="rtsp://helixserver.example.com/video1.rm" begin="20.5s"/>

In the preceding markup, the begin attribute delays the clip playback for 20.5 seconds. Were this clip in a sequence, there would be 20.5 seconds of blank time before the clip starts.

Tip: You can also use begin in <seq> and <par> tags to delay playback of the entire sequence or parallel group. Parallel groups are described in "Playing Clips in Parallel".

View it now! (requirements for viewing this sample)
This demonstration explains basic begin values.

Using Internal Clip Begin and End Times

The clipBegin and clipEnd attributes specify a clip's internal timing marks where playback begins and ends. They allow you to play just part of a clip that has an internal timeline, such as an audio, video, or animation clip. They have no effect on groups or static clips such as still images, though. The following example uses clipBegin and clipEnd with a video clip:

<video src="video1.rm" clipBegin="10s" clipEnd="50s"/>

Here, the clip starts playing at its internal 10-second mark rather than at its encoded beginning. It stops when it reaches its 50-second mark, having played for a total of 40 seconds.

Tip: The clipBegin and clipEnd attributes affect a clip in a SMIL presentation the way that start and end affect a clip listed in a Ram file. For more on start and end, see "Controlling How a Presentation Initially Displays".

Warning! Do not use clipBegin and clipEnd with live broadcasts, or when delivering clips with a Web server. These attributes function only for prerecorded clips streamed by Helix Universal Server.

View it now! (requirements for viewing this sample)
This demonstration explains basic clipBegin and clipEnd values.

Specifying a Duration

The dur attribute controls how long a clip or group plays. The following example ends the video after 85 seconds, regardless of the length of the clip's internal timeline. If the video's timeline is shorter than 85 seconds, the video's last frame appears frozen onscreen until the duration elapses:

<video src="video1.rm" dur="85s"/>

A common use of dur is to control how long a static clip such as an image appears onscreen. The following example displays an image for two minutes:

<img src="button1.gif" dur="2min"/>

For More Information: See also the fill attribute, which is described in "Setting Clip Fills".

View it now! (requirements for viewing this sample)
This demonstration shows the use of a basic dur value.

Using Advanced Clip and Timing Features

The clip and timing attributes explained in this chapter are a small sample of the extensive SMIL 2.0 features described in RealNetworks Production Guide. You can download that guide from http://service.real.com/help/library/encoders.html to learn how to do the following:


RealNetworks, Inc. ©2002 RealNetworks, Inc. All rights reserved.
For more information, visit RealNetworks
Click here if the Table of Contents frame is not visible at the left side of your screen.
previous next