previous next

Chapter 18: Switching

SMIL switching gives you a powerful way to provide different clips that RealOne Player chooses between based on certain criteria. For example, you can have each RealOne Player select an audio track based on each viewer's language preference. This chapter explains how to set up switch groups to stream different clips to different audiences.

Understanding Switching

SMIL switching is a powerful means to tailor presentations for different audiences without making viewers choose which presentation they wish to view. In cases such as language choice, SMIL switching occurs automatically based on a preference the viewer has set in RealOne Player. In other cases, such as available bandwidth or monitor size, switching is based on an attribute that the viewer does not control. In all cases, however, RealOne Player automatically makes the choice without input from the viewer.

Tip: When you want viewers to choose options themselves, use an <excl> tag, not a <switch> tag. For more on the <excl> tag, see "Creating an Exclusive Group".

Note: The following sections demonstrate switching with clips recorded in different languages. Keep in mind, though, that the same principles apply to switching through other criteria, such as bandwidth or monitor size.

Creating a Switch Group

A switch group starts with a <switch> tag and ends with a </switch> tag. Between these tags, you list multiple options, such as multiple clip source tags, that each contain a test attribute. RealOne Player evaluates the options in the order you list them, choosing the first option that it can play. For example, in the following simple <switch> group, the systemLanguage test attributes cause RealOne Player to choose one of two audio clips based on its language preference:

<switch>
<audio src="french.rm" systemLanguage="fr"/>
<audio src="german.rm" systemLanguage="de"/>
</switch>

Only RealOne Players in which the viewer has selected French (fr) as the language preference will choose the first clip. Only RealOne Players in which the viewer has selected German (de) as the language preference will choose the second clip. A RealOne Player with another language preference will not play either clip: it simply ignores the clips in the <switch> group and proceeds to the next part of the presentation. Hence, a RealOne Player either plays just one clip from a <switch> group, or it plays no clip. But it never plays more than one option.

Adding a Default Option to a Switch Group

To reach the widest audience of viewers, a <switch> group needs to have a default option. Without this option, certain RealOne Players may not play any clips in the group. A default option must satisfy these criteria:

The following example modifies the preceding example to add an English- language clip as the default choice:

<switch>
<audio src="french.rm" systemLanguage="fr"/>
<audio src="german.rm" systemLanguage="de"/>
<audio src="english.rm"/>
</switch>

Note that the English-language clip is listed last and does not include a systemLanguage test attribute, making it the default. In this example, any RealOne Player with a preference set to a language other than French or German will choose the English clip. For example, all RealOne Players with a language preference for Swedish, Korean, English, and so on choose the English-language clip.

Using Inline Switching

It is not always necessary to use a <switch> tag for switching. You can also use inline switching, which adds test attributes to clip source tags in a <par> or <seq> group. When RealOne Player encounters a test attribute, it evaluates the attribute to determine if it should play or skip the clip. In the following example of a parallel group, RealOne Player always plays the Flash clip, and then chooses the French or German audio clip based on its language preference:

<par>
<ref src="cartoon.swf" region="playback"/>
<audio src="french.rm" systemLanguage="fr"/>
<audio src="german.rm" systemLanguage="de"/>
</par>

Choosing Inline Switching or a Switch Group

Although useful in many situations, inline switching cannot provide a default option, making it less powerful than a <switch> group. Consider the following example, which attempts to add a default English-language clip to the preceding example:

<par>
<!-- This is NOT a good example of switching. -->
<ref src="cartoon.swf" region="playback"/>
<audio src="french.rm" systemLanguage="fr"/>
<audio src="german.rm" systemLanguage="de"/>
<audio src="english.rm"/>
</par>

The parallel group shown above will work for every RealOne Player, except those with a French or German language preference! For instance, a RealOne Player with a language preference for French plays the Flash (.swf) clip, the French RealAudio clip, and the English-language clip, which has no systemLanguage attribute that ties it to a language preference. Hence, the viewer hears an incomprehensible blend of French and English.

Only a <switch> tag causes RealOne Player to evaluate all options as a group and choose only one option. The following example illustrates the correct way to add the default, English-language choice to the parallel group shown above:

<par>
<!-- This is a good example of switching. -->
<ref src="cartoon.swf" region="playback"/>
<switch>
<audio src="french.rm" systemLanguage="fr"/>
<audio src="german.rm" systemLanguage="de"/>
<audio src="english.rm"/>
</switch>
</par>

Available Test Attributes

The following table lists the test attributes available for switching. These attributes are described in detail in the remainder of this chapter.

Switch Attributes
Attribute Value Tests For Reference
systemAudioDesc on|off descriptions preference click here
systemBitrate bits_per_second total available bandwidth click here
systemCaptions on|off captions preference click here
systemComponent component component or version click here
systemCPU CPU_type computer CPU type click here
systemLanguage language_code language preference click here
systemOperatingSystem OS_name computer operating system click here
systemOverdubOrSubtitle overdub|subtitle overdubbing or subtitle preference click here
systemRequired prefix namespace support click here
systemScreenDepth 1|4|8|24|32 monitor color bit depth click here
systemScreenSize heightXwidth monitor size click here

Tips for Writing Switch Groups

Switching Between Language Choices

When source clips are in different languages, use a test attribute of systemLanguage in the clip source tag or group tag. The following example shows a video slideshow with separate audio narrations in French, German, Spanish, Japanese, Korean, and English. Each RealOne Player requests the same slideshow, but chooses an audio clip based on its language preference (Tools>Preferences>Content) and its evaluation of the systemLanguage values:

<par>
<ref src="seattle_slides.rp"/>
<!-- select audio based on RealOne Player language preference setting -->
<switch>
<audio src="seattle_french.rm" systemLanguage="fr"/>
<audio src="seattle_german.rm" systemLanguage="de"/>
<audio src="seattle_spanish.rm" systemLanguage="es"/>
<audio src="seattle_japanese.rm" systemLanguage="ja"/>
<audio src="seattle_korean.rm" systemLanguage="ko"/>
<audio src="seattle_english.rm"/>
</switch>
</par>

The last audio option in the preceding example is the default. Because the last option does not have a test attribute, a RealOne Player that does not have French, German, Spanish, Portuguese, Japanese, or Korean set as its preferred language chooses the English clip.

For More Information: See the examples in "Subtitles and HTML Pages in Different Languages" for more demonstrations of how to use systemLanguage.

Setting Language Codes

Appendix I lists the codes used as systemLanguage values. In some cases, a primary language code has variation codes. For instance, es is the primary code for Spanish, corresponding to Spanish as spoken in Spain. This code has several variations, such as es-mx for Mexican Spanish and es-pr for Puerto Rican Spanish. When variation codes are used, RealOne Player uses the following rules to select a clip:

If you have different clips for different language variations, list the clip that corresponds to the primary code as the last option, as shown here:

<switch>
<audio src="mexico.rm" systemLanguage="es-mx"/>
<audio src="puertorico.rm" systemLanguage="es-pr"/>
<audio src="defaultspanish.rm" systemLanguage="es"/>
</switch>

In the preceding example, RealOne Players with a preference for Mexican Spanish (es-mx) choose the first clip. RealOne Players with a preference for Puerto Rican Spanish (es-pr) choose the second clip. All other RealOne Players with a preference for any variation of Spanish choose the last clip. For instance, a RealOne Player with a preference for Chilean Spanish chooses the es option because its preferred variation (es-cl) is not listed.

Providing Subtitles or Overdubbing

For clips in foreign languages, RealOne Player viewers can set a preference for subtitles or overdubbing. The systemOverdubOrSubtitle attribute tests for this preference, displaying clips based on the viewer's choice. It can have one of two values, either overdub or subtitle. Suppose that you have three versions of a RealVideo clip:

  1. an original French version (original.rm)
  2. a version dubbed in English (dubbed.rm)
  3. the original French version with English subtitles (titled.rm)

You can use systemOverdubOrSubtitle along with systemLanguage in a <switch> group as shown in the following example:

<switch>
<!-- Version for RealOne Players with a preference for English and overdubbing. -->
<video src="dubbed.rm" systemLanguage="en" systemOverdubOrSubtitle="overdub"/>
<!-- Version for RealOne Players with a preference for English and subtitling. -->
<video src="titled.rm" systemLanguage="en" systemOverdubOrSubtitle="subtitle"/>
<!-- Version for RealOne Players with a language preference other than English. -->
<video src="original.rm"/>
</switch>

In the preceding example, RealOne Players with a preference for English and overdubbing play the first clip. Any other RealOne Player preferring English plays the second clip. The original French clip is listed last with no systemLanguage attribute. This makes it the default played by RealOne Players that prefer French or another language besides English.

Note: In the preceding example, the second clip does not need to specify subtitle explicitly. The systemOverdubOrSubtitle attribute uses only overdub or subtitle as its value. Because the first clip takes the overdub value, only the subtitle value is left for the second clip.

Switching Between Bandwidth Choices

To stream different clips to viewers at different connection speeds, use the systemBitrate test attribute to define options each RealOne Player can choose based on the total amount of bandwidth it has available. The systemBitrate attribute takes as a value the approximate bits per second required to stream the whole presentation. The following sample <switch> tag lists two different RealPix presentations. The first is for connections that have at least 80 Kbps of bandwidth. The second is for slower connections, down to 28.8 Kbps modems:

<switch>
<ref src="slides1.rp" systemBitrate="80000"/>
<ref src="slides2.rp" systemBitrate="20000"/>
</switch>

As shown above, list the bandwidth choices from fastest to slowest. RealOne Player evaluates options in order, selecting the first option it can play. If the 20,000 bps option were first, a RealOne Player with a high-speed connection would choose it because it is the first viable option. Also ensure that the last option satisfies the slowest connection speed you want to support. If the last choice is systemBitrate="60000", for example, RealOne Players on modems will not play the presentation because its bandwidth requirement is too high.

The more complex example below shows three sets of clips. Each <par> tag has a systemBitrate attribute that lists the approximate bandwidth the clips as a whole consume. Note that each group uses the same RealText clip, but has different RealAudio and RealPix clips created for its bandwidth:

<switch>
<par systemBitrate="225000">
<!--RealOne Players with 225 Kbps or faster connections choose this group-->
<audio src="music1.rm"/>
<ref src="slides1.rp" region="images"/>
<textstream src="narration.rt" region="text"/>
</par>
<par systemBitrate="80000">
<!--RealOne Players with connections between 80 and 225 Kbps get this group-->
<audio src="music2.rm"/>
<ref src="slides2.rp" region="images"/>
<textstream src="narration.rt" region="text"/>
</par>
<par systemBitrate="20000">
<!--RealOne Players with connections between 20 and 80 Kbps get this group-->
<audio src="music3.rm"/>
<ref src="slides3.rp" region="images"/>
<textstream src="narration.rt" region="text"/>
</par>
</switch>

For More Information: The table "Maximum Streaming Rates" gives bandwidth guidelines for various network connections.

Tip: Helix Producer Plus, which you can purchase and download from http://www.realnetworks.com/products/producer/index.h tml, installs a bandwidth simulator in RealOne Player that you can use to test different streaming speeds for a SMIL presentation streamed by Helix Universal Server.

Switching with SureStream Clips

With RealAudio or RealVideo clips encoded for multiple bit rates with SureStream technology, you may or may not need to use the <switch> tag with a systemBitrate attribute. The following guidelines will help you to make this decision:

Enhancing Presentation Accessibility

RealOne Player users who are sight- or hearing-impaired can set accessibility preferences (Contents under Tools>Preferences) that give them audio descriptions or captions when those options are available. You can match RealOne Player viewers to these options with the systemAudioDesc and systemCaptions attributes. Both attributes, which you can use together or singly, take a value of either on or off. Suppose you have three versions of a video clip:

  1. An original version for viewers with no accessibility preference (video.rm).
  2. A version for sight-impaired viewers with a preference for audio descriptions (video_descriptions.rm). A video with audio descriptions might consist of a standard video that pauses intermittently while a separate audio track encoded in the clip describes upcoming scenes.
  3. A version for hearing-impaired viewers with a preference for captions (video_captions.rm). A video with captions might consist of a standard video that includes encoded captions similar to subtitles, but in the same language as the video's audio track.

You can use inline switching with the systemAudioDesc and systemCaptions attributes as shown in the following example to choose between clips based on the viewer's accessibility preference:

<seq>
<video src="video_descriptions.rm" systemAudioDesc="on"/>
<video src="video_captions.rm" systemCaptions="on"/>
<video src="video.rm"/>
</seq>

For More Information: See "System Captions Using RealText" for an example of using RealText to provide system captions.

Switching Based on the Viewer's Computer

Several <switch> tag attributes—systemCPU, systemOperatingSystem, systemScreenSize, and systemScreenDepth—let you switch between clips or groups based on the viewer's computer hardware or software. This lets you tailor a presentation's size or clip types, for example, based on the features of the machine running RealOne Player.

Switching for CPU Type

The systemCPU attribute lets you switch clips based on the processor for the RealOne Player computer. This attribute identifies the computer processor but no other machine attributes, such as the computer's clock speed, available memory, or operating system. The following table lists the possible values for the systemCPU attribute.

systemCPU Attribute Values
Attribute Value Computer Processor Selected
alpha Compaq Alpha processor
arm Unix-based server processor
arm32 Unix-based server processor
hppa1.1 Hewlett-Packard Unix-based server processor
m68k pre-PowerPC Macintosh
mips Unix-based server processor
ppc PowerPC Macintosh and Linux
rs6000 IBM Unix-based server processor
unknown unknown processor type
vax DEC VAX running VMS or Unix
x86 Intel chip set for Windows and Linux PCs and servers

Note: The preceding table lists all systemCPU attribute values defined for SMIL. This does not mean, however, that RealOne Player is available for each hardware platform.

Switching for Operating System

The systemOperatingSystem attribute lets you switch clips based on the operating system running on the RealOne Player computer. This attribute does not discriminate between various versions of an operating system, however. The following table lists the values for systemOperatingSystem. The last column indicates if a version of RealOne Player is available for that operating system. Note, however, that RealOne Player availability is subject to change.

systemOperatingSystem Attribute Values
Attribute Value Operating System Selected RealOne Player?
aix IBM AIX version of Unix yes
beos Be operating system no
bsdi Berkeley Software Design's version of Unix no
dgux Data General UX version of Unix no
freebsd FreeBSD version of Unix no
hpux HP-UX version of Unix yes
irix Silicon Graphics Irix version of Unix yes
linux Any Linux distribution yes
macos Any Macintosh operating system, including MacOSX yes
ncr NCR network operating system no
nec NEC version of Unix no
netbsd Network BSD version of Unix no
nextstep NeXT operating system no
nto NTO version of Unix no
openbsd Open BSD version of Unix no
openvms Open VMS no
os2 IBM OS/2 no
osf Open Software Foundation's version of Unix no
palmos Palm operating system no
qnx QNX Software System's realtime platform no
rhapsody Macintosh OSX Server no
sco Caldera version of Unix (fomerly Santa Cruz Operations) no
sinix Siemens Nixdorf version of Unix no
solaris Sun Solaris version of Unix yes
sunos Sun version of Unix pre-dating Solaris no
unixware Caldera version of Unix (formerly Novell) yes
unknown unknown operating system n/a
win16 Microsoft Windows 16-bit OSes yes
win32 Microsoft Windows 32-bit OSes yes
win9x Microsoft Windows 95/98/ME yes
wince Microsoft Windows CE and PocketPC yes
winnt Microsoft Windows NT/2000/XP yes

Switching for Monitor Size or Color Depth

Two test attributes, systemScreenSize and systemScreenDepth, let you switch clips based on the size and color capability of the monitor displaying RealOne Player. They are useful if you have different versions of the same video in different sizes or different color depths, for example.

Specifying a Monitor Size

The systemScreenSize attribute uses a pixel measurement value in the form heightXwidth. The value specifies that the monitor displaying RealOne Player must be of the given size or larger. The following are common systemScreenSize values:

1024X1280 common size for 21-inch monitors or larger
768X1024 common size for 17-inch monitors or larger
600X800 common size for 15-inch monitors or larger
480X640 smallest desktop monitor size in general use

Note: You must use a capital "X". Note, too, that monitor sizes are commonly referred to in a width-by-height format, such as 640-by-480. With SMIL, though, you must specify height first.

Because a monitor must be at least the specified size for RealOne Player to choose an option, always list options from the largest to the smallest screen size as shown above. If you listed systemScreenSize="480X640" first, for example, all RealOne Players on standard desktop computers would choose that option because all standard desktop monitors are at least that size.

Tip: Keep in mind that computer users can generally set their monitor resolutions differently. Some 17-inch monitors may have a resolution of 768X1024 for example, while others are set to 600X800.

Specifying a Color Depth

The systemScreenDepth attribute uses an integer value that specifies the color bit depth of the monitor. The monitor must have the given bit depth or higher to play the clip. The following are common systemScreenDepth values:

32 millions of colors
24 millions of colors
16 thousands of colors
8 256 colors
4 16 colors
1 black-and-white

Because a monitor must have at least the specified color depth for RealOne Player to choose an option, always list options from the highest bit depth to the lowest as shown above. If you listed systemScreenDepth="8" first, for example, all RealOne Players on standard color monitors would choose that option because all standard color monitors can display at least 256 colors.

Checking Components and Version Numbers

Using the systemRequired and systemComponent attributes, you can define an element that plays only if RealOne Player (or another SMIL-based media player) is above a specific version number, or possesses a certain component, such as a plug-in required to render a clip. The following sections describe how to use these attributes within SMIL 2.0, and how to use them to provide backward-compatibility with SMIL 1.0.

Defining Test Attributes in SMIL 2.0

The following abstract example illustrates how systemRequired and systemComponent attributes work in SMIL 2.0:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:prefix="customizations_namespace">
<body>
<switch>
<ref systemRequired="prefix" prefix:systemComponent="component"
...clip to use if the player has the specified component.../>
<ref ...clip to use if the player does not have the specified component.../>
</switch>
</body>
</smil>

The <switch> tag in this example enables RealOne Player to choose between two clips, the second of which is a default choice that plays if RealOne Player does not meet the requirements of the first clip.

The Customizations Namespace

The <smil> tag in the preceding example defines a customizations namespace that is specific to the media player being tested:

xmlns:prefix="customizations_namespace"

A customizations namespace is required because the systemComponent attribute values are different for each media player. For example, the systemComponent value that tests for the version number of RealOne Player is different from a systemComponent value that tests for the version number of a different SMIL-based media player. The namespace defines the values that the media player can expect to encounter for systemComponent.

For More Information: For more on namespaces, see "Using Customized SMIL Attributes".

The systemRequired Attribute

The systemRequired attribute takes as a value the prefix for the customizations namespace. This is necessary because a media player that does not handle a certain attribute, such as a specific systemComponent value, ignores the attribute but still plays the element. The systemRequired attribute overrides this default behavior, making the media player ignore the element entirely if the player does not recognize the customizations namespace.

The systemComponent Attribute

The systemComponent attribute selects a component or property that RealOne Player or another media player must possess, such as a certain version number. The values are specific to each media player.

Note: A later version of this manual will describe components and properties that you can test for in RealOne Player. Currently, the primary use of systemComponent is to add SMIL 2.0 features to a SMIL 1.0 file, as explained in the next section.

Combining SMIL 2.0 with SMIL 1.0

The previous section describes how to use systemComponent and systemRequired within a SMIL 2.0 environment. This section explains how you can use systemComponent and system-required (the SMIL 1.0 version of systemRequired) to create a file that plays as SMIL 1.0 in RealPlayer 7 and RealPlayer 8 (but not RealPlayer G2), and contains enhanced SMIL 2.0 features for RealOne Player. This lets you add SMIL 2.0 features to existing SMIL 1.0 files, for instance.

Tip: Because of the many differences between SMIL 1.0 and SMIL 2.0, RealNetworks does not recommend creating a complex SMIL file that plays as SMIL 2.0 in RealOne Player and as SMIL 1.0 in RealPlayer 7 and 8. Use this backward- compatible method only for adding a small number of SMIL 2.0 features to existing SMIL 1.0 presentations. Otherwise, create separate SMIL 1.0 and 2.0 files.

Testing for the Player Version

To add SMIL 2.0 functionality to a SMIL 1.0 file, you use systemComponent and system-required to test the player version on each SMIL 2.0 element. This enables RealPlayer 7 and 8 to ignore the element. The following example modifies the SMIL 2.0 example in the preceding section, adding the attributes and values that are specific to testing for the RealPlayer version number:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:cv="http://features.real.com/systemComponent">
<body>
<switch>
<ref system-required="cv"
cv:systemComponent="http://features.real.com/?component;player=6.0.10"
...clip for RealOne Player to play.../>
<ref ...clip earlier versions of RealPlayer to play.../>
</switch>
</body>
</smil>

In this example, each player has a choice of two clips specified by <ref/> tags. The first <ref/> tag requires that the player be version 6.0.10 (RealOne Player) or later. Earlier versions of RealPlayer choose the second, default option.

The Customizations Namespace

To test for the RealPlayer version number, you must include the following namespace. Be sure to use the cv prefix, too. In SMIL 2.0, prefixes are user- definable. For RealPlayer 7 and 8, however, the cv prefix is required:

xmlns:cv="http://features.real.com/systemComponent"

Note that the preceding example also declares the SMIL 2.0 namespace:

xmlns="http://www.w3.org/2001/SMIL20/Language"

RealPlayer 7 and 8 do not recognize the SMIL 2.0 namespace, so they ignore it and play the file as SMIL 1.0. Because of this namespace, though, RealOne Player plays the file as SMIL 2.0, letting you add SMIL 2.0 features.

The system-required Attribute

The system-required attribute is the SMIL 1.0 version of systemRequired. It ensures that the media player recognizes the customizations namespace. If the player doesn't, it ignores the element entirely.

The systemComponent Attribute

The systemComponent attribute in the preceding example uses the cv prefix of the customizations namespace, and specifies that the player must be version 6.0.10 or later, which is the major version number for RealOne Player. The syntax is specific to RealNetworks media players, and should be entered exactly as shown:

cv:systemComponent="http://features.real.com/?component;player=6.0.10"

For More Information: See "Backward-Compatible SMIL File" for an example of how to add SMIL 2.0 transparency extensions to a SMIL 1.0 file.

Switch Group Examples

The following examples illustrate different ways to use switching. Note that there are many applications for switching, and many ways to write SMIL presentations that include switching. To view more examples, get the zipped HTML version of this guide as described in "How to Download This Guide to Your Computer", and view the Sample Files page.

Multiple Test Attributes

Using multiple test attributes in a <switch> group, you can have RealOne Player choose clips based on combined criteria, such as both available bandwidth and language preference. There are two ways to do this:

Example 1: Multiple Test Attributes for Each Clip

In the following example, the first two RealAudio clips have two test attributes each—one for language and one for bandwidth. Both attributes must be viable for RealOne Player to choose the clip. Because RealOne Player evaluates the <switch> choices from top to bottom, selecting the first viable option, the last two choices do not have language attributes. This lets all RealOne Players other than those with French selected as their language preference choose between the two English-language clips, based on their available bandwidth:

<switch>
<!-- French language choices -->
<audio src="french2.rm" systemLanguage="fr" systemBitrate="47000"/>
<audio src="french1.rm" systemLanguage="fr" systemBitrate="20000"/>
<!-- English language choices (default) -->
<audio src="english2.rm" systemBitrate="47000"/>
<audio src="english1.rm" systemBitrate="20000"/>
</switch>

Example 2: Nested <switch> Groups

The next example adds RealText clips in both French and English to the presentation possibilities. Here, <switch> groups are nested so that RealOne Players with French set as their language preference play the French RealText clip and choose from the set of French-language RealAudio clips, based on available bandwidth. All other RealOne Players play the English RealText clip and choose from the set of English-language RealAudio clips:

<switch>
<!-- Choose French as the language. -->
<par systemLanguage="fr">
<textstream src="frenchcredit.rt" region="credits_region" fill="remove"/>
<switch>
<!-- Choose fast or slow bit rate for French audio -->
<audio src="french2.rm" systemBitrate="47000"/>
<audio src="french1.rm" systemBitrate="20000"/>
</switch>
</par>
<!-- Choose English as the language. This is the default. -->
<par>
<textstream src="enlgishcredits.rt" region="credits_region" fill="remove"/>
<switch>
<!-- Choose fast or slow bit rate for English audio -->
<audio src="english2.rm" systemBitrate="47000"/>
<audio src="english1.rm" systemBitrate="20000"/>
</switch>
</par>
</switch>

Different Video Sizes Chosen Automatically

As described in "Different Clip Dimensions for Different Bandwidths", you can encode different sizes of the same video, streaming a small clip over slow modems and a larger clip (or clips) over faster connections. Reducing the video size for slower connections ensures that the video's frame rate and visual quality remain high. For example, you could create the three clips listed in the following table.

RealVideo Clips at Different Sizes
Clip Name Dimensions SureStream Audiences systemBitrate value
videosmall.rm 176 x 132 28.8 and 56 Kbps Modems 20000
videomedium.rm 240 x 180 ISDN and corporate LANs 45000
videobig.rm 320 x 240 256, 384, and 512 Kbps DSL and cable modems 225000

In the following example, each <switch> tag test attribute uses the target bit rate of its clip's slowest SureStream stream. The <switch> tag then presents the three RealVideo choices to RealOne Player from fastest to slowest:

<switch>
<video src="videobig.rm" systemBitrate="225000" region="video_region" .../>
<video src="videomedium.rm" systemBitrate="45000" region="video_region" .../>
<video src="videosmall.rm" systemBitrate="20000" region="video_region" .../>
</switch>

For More Information: Target bit rates are listed in the table "Maximum Streaming Rates".

Subtitles and HTML Pages in Different Languages

The section "Switching Between Language Choices" explains the basics of using systemLanguage to play different clips based on viewer language preferences (Tools>Preferences>Content). The following examples show how to augment a video clip with RealText subtitles in different languages, and how to display different pages in the related info pane based on language choice.

Example 1: RealText Subtitles

The following sample SMIL file defines a small text region that overlays the bottom portion of a video clip. Inline switching displays RealText subtitles if the viewer has a language preference set to any variation of French or Spanish. Viewers preferring other languages see only the video:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language"
xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">
<head>
<meta name="title" content="Semi-Transparent Video Subtitles"/>
<meta name="copyright" content="(c)2002 RealNetworks, Inc."/>
<layout>
<root-layout width="320" height="240" backgroundColor="black"/>
<region id="video_region" z-index="1"/>
<region id="text_region" height="35" bottom="0" left="10" z-index="2"/>
</layout>
</head>
<body>
<par>
<video src="video3.rm" region="video_region" fill="remove"/>
<textstream src="subtitles_fr.rt" systemLanguage="fr" region="text_region"
rn:backgroundOpacity="45%" fill="freeze"/>
<textstream src="subtitles_es.rt" systemLanguage="es" region="text_region"
rn:backgroundOpacity="45%" fill="freeze"/>
</par>
</body>
</smil>

For More Information: In the preceding sample, the rn:backgroundOpacity attribute is used on the RealText clips to render their backgrounds partially transparent. For more on this attribute, see "Creating Transparency in a Clip's Background Color". Chapter 6 explains RealText.

View it now! (requirements for viewing this sample)
This first sample overlays a video with semi-transparent French or Spanish subtitles if you set your RealOne Player language preference to any variation of French or Spanish, respectively. The second sample is similar in function, but opaque subtitles display below the video.

Example 2: Different HTML Pages for Different Languages

Because SMIL lets you control HTML pages from your media, it's easy to display different HTML pages in different languages based on the viewer's language preference. The following sample, which omits the SMIL header, automatically displays one of three different HTML pages in the related info pane. The first page appears if the viewer prefers French. The second page displays for Spanish speakers. The third page, which has no systemLanguage attribute, is the default choice that appears for all other viewers:

<body>
<video id="main" src="video2.rm" region="video_region" fill="freeze">
<switch>
<area systemLanguage="fr" href="http://www.example.com/french.htm"
actuate="onLoad" external="true" rn:sendTo="_rpcontextwin"
sourcePlaystate="play">
<rn:param name="width" value="300"/>
<rn:param name="height" value="280"/>
</area>
<area systemLanguage="es" href="http://www.example.com/spanish.htm"
actuate="onLoad" external="true" rn:sendTo="_rpcontextwin"
sourcePlaystate="play">
<rn:param name="width" value="300"/>
<rn:param name="height" value="280"/>
</area>
<area href="http://www.example.com/default.htm" actuate="onLoad"
external="true" rn:sendTo="_rpcontextwin" sourcePlaystate="play">
<rn:param name="width" value="300"/>
<rn:param name="height" value="280"/>
</area>
</switch>
</video>
</body>

Note that the body of this SMIL file consists of just one clip source tag (<video>...</video>). Within these tags, a switch group (<switch>...</switch>) contains three hyperlinks (<area>...</area>). Once RealOne Player chooses a hyperlink based on the viewer language preference, the linked page opens automatically, setting the related info pane's size.

For More Information: To find out more about SMIL links that open HTML pages, see "Linking to HTML Pages".

View it now! (requirements for viewing this sample)
This sample demonstrates language switching for HTML pages. The same clip plays, but a different related info page appears if you set your RealOne Player language preference to French, Spanish, Japanese, or Swedish.

System Captions Using RealText

As the section "Enhancing Presentation Accessibility" explains, you can use the systemCaptions attribute to display captions for hearing-impaired viewers. A viewer can turn on the captions preference by giving the Tools>Preferences command, then selecting the Content pane.

The following examples demonstrate various ways to display RealText captions for an audio track, but you can use any type of clip to provide captions. The systemCaptions="on" attribute simply tells RealOne Player to play a certain clip if the viewer has turned the captions preference on. There are no requirements for what type of clip to use for captions, though.

Tip: Captions are different from subtitles. Captions, which are typically in the same language as the clip audio, are meant for hearing-impaired viewers who have set the captions preference on. Subtitles are for all viewers, and are generally in languages different from the clip audio. You can display subtitles based on the viewer's language preference, which is described in "Switching Between Language Choices".

For More Information: Chapter 6 explains how to write a RealText clip. See Chapter 12 for information about layouts.

Example 1: Transparent RealText Overlay

Although it may not be suitable in all cases, the simplest way to provide captioning is to overlay a clip with a RealText clip that has a background rendered transparent or semi-transparent through the rn:backgroundOpacity attribute. To do this, you define two regions, one for the video, and one for the captions, using the z-index attribute to ensure that the captions appear in front, as shown in the following example:

<layout>
<root-layout width="320" height="240" backgroundColor="black"/>
<region id="video_region1" z-index="1"/>
<region id="text_region" height="40" bottom="0" left="10" z-index="2"/>
</layout>

You then play the RealText clip in parallel with the main clip, using systemCaptions="on" to display the RealText clip only in RealOne Players that have a preference for system captions. Because system captions are either on or off, you can easily use inline switching (no <switch> tag), as shown here:

<par>
<video src="video.rm" region="video_region1" fill="remove"/>
<textstream src="transparentcaptions.rt" region="text_region"
systemCaptions="on" rn:backgroundOpacity="45%" fill="remove"/>
</par>

For More Information: For more on rn:backgroundOpacity, see "Adjusting Clip Transparency and Opacity"

View it now! (requirements for viewing this sample)
This sample overlays a video with captions when the systems captions preference is turned on. If the preference is turned off, just the video displays.

Example 2: Caption Region

If you do not want to overlay the video as described in the preceding example, you can create a separate region for the captions through your SMIL file layout. The following layout is similar to that used in the preceding example, except that the captions region appears below the video region rather than on top of it:

<layout>
<root-layout width="320" height="300" backgroundColor="black"/>
<region id="video_region" height="240"/>
<region id="text_region" height="40" top="260" left="10"/>
</layout>

If you play a video in parallel with a captions clip as shown in the preceding example, the captions region would appear blank for viewers who have the captions preference turned off. Alternatively, you can create a "filler clip" that displays in the captions region when captions are off. This clip might simply thank the viewer for watching the presentation. The following example demonstrates how to do this:

<par>
<video src="video3.rm" region="video_region" fill="remove"/>
<switch>
<textstream src="videocaptions.rt" region="text_region" systemCaptions="on"/>
<textstream src="fillercaptions.rt" region="text_region" systemCaptions="off"/>
</switch>
</par>

View it now! (requirements for viewing this sample)
This sample creates a separate captions area that displays filler text if the captions preference is turned off.

Example 3: Media Playback Pane Resized for Captions

This example demonstrates how to use systemCaptions in <layout> tags to change layouts depending on whether or not captions are displayed. The following layout creates a captions region only when captions are turned on. Note that in each layout, the video region has a unique ID, which is required by SMIL. But both video regions have the same name:

<switch>
<layout systemCaptions="on">
<root-layout width="320" height="300" backgroundColor="black"/>
<region id="video_region1" regionName="video" height="240"/>
<region id="text_region" height="40" top="260" left="10"/>
</layout>
<layout systemCaptions="off">
<root-layout width="320" height="240" backgroundColor="black"/>
<region id="video_region2" regionName="video"/>
</layout>
</switch>

Tip: Although the preceding example uses systemCaptions in the <layout> tag, you could use the attribute in <root-layout/> and <region/> tags instead to display or hide individual regions based on RealOne Player's captions setting.

In the SMIL body, you then assign clips to the regions. Note that the following markup assigns the single video clip to a region through the region name instead of the region ID. If you didn't use the region name, you'd need to create two <video/> tags, one assigned to video_region1, the other assigned to video_region2. Each tag would require a systemCaptions attribute to turn the tag on or off depending on the captions preference. With the following method, only the RealText clip uses the systemCaptions attribute:

<par>
<video src="video.rm" region="video" .../>
<textstream src="captions.rt" region="text_region" systemCaptions="on" .../>
</par>

For More Information: See "Setting Region IDs and Names" for more on region names.

View it now! (requirements for viewing this sample)
This sample resizes the media playback pane and displays captions if the captions preference is turned on. The next, more sophisticated sample includes buttons that let the viewer resize the captions. Here, resizing is accomplished through SMIL animations.

Backward-Compatible SMIL File

The section "Combining SMIL 2.0 with SMIL 1.0" explains the basics of using systemComponent and system-required to create a SMIL 1.0 presentation for RealPlayer 7 and 8 that includes enhanced SMIL 2.0 features for RealOne Player. This sample guides you step-by-step through the process of adding a semi-transparent GIF logo to a video clip. In RealPlayer 7 and 8, which do not support transparency, only the video plays. In RealOne Player, the logo appears in front of the video in the lower-right corner of the media playback pane. The following is the SMIL 1.0 file that plays the video:

<smil>
<head>
<meta name="title" content="Video Playback"/>
<meta name="copyright" content="(c)2002 RealNetworks, Inc."/>
<layout>
<root-layout width="320" height="240" background-color="white"/>
<region id="video_region" width="320" height="240" z-index="1"/>
</layout>
</head>
<body>
<video src="video1.rm" region="video_region" fill="remove"/>
</body>
</smil>

To update the preceding SMIL 1.0 file:

  1. Add the required namespaces to the <smil> tag.
  2. You need to add the namespaces for SMIL 2.0 and the RealNetworks extensions, which provide support for transparency. RealPlayer 7 and 8 ignore these namespaces. All players starting with RealPlayer 7 recognize the systemComponent namespace, however:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language" 
    xmlns:rn="http://features.real.com/2001/SMIL20/Extensions"
    xmlns:cv="http://features.real.com/systemComponent">

    Note: In presentations played by RealPlayer 7 and 8, the cv prefix for the systemComponent namespace is required.

  3. Modify the layout.
  4. The preceding SMIL 1.0 file contains a single video region, so the GIF logo requires another region. Even though the updated file is technically SMIL 2.0, it uses SMIL 1.0 layout features, as well as SMIL 1.0 attribute names like background-color. Although you could add SMIL 2.0 layout features such as subregions, you'd need to hide them from earlier players. It's therefore easier to use a SMIL 1.0 layout, which is forward-compatible with SMIL 2.0 and RealOne Player:

    <layout>
    <root-layout width="320" height="240" background-color="white"/>
    <region id="video_region" width="320" height="240" z-index="1"/>
    <region id="logo_region" width="52" height="46" top="190" left="260"
    fit="meet" z-index="2"/>
    </layout>

    For More Information: For information about SMIL 1.0 attributes, see RealSystem iQ Production Guide for Release 8.

  5. Add the image clip.
  6. The SMIL 1.0 file's content consists of a video clip. To display the logo, you play the video and the GIF image in parallel. The system-required and cv:systemComponent attributes ensure that the logo clip is played only by a RealNetworks media player with a version number of at least as high as 6.0.10, which is the RealOne Player major version number. To RealPlayer 7 and 8, the body contains just the video clip:

    <body>
    <par>
    <video src="video3.rm" region="video_region" fill="remove"/>
    <img system-required="cv"
    cv:systemComponent="http://features.real.com/?component;player=6.0.10"
    src="prodlogo.gif" rn:mediaOpacity="50%" id="rn_logo"
    region="logo_region" dur="10s" fill="freeze"/>
    </par>
    </body>

    For More Information: For details about rn:mediaOpacity, see "Adjusting Clip Transparency and Opacity".

  7. Test the SMIL file.
  8. Always test your presentation by opening it in RealOne Player to verify that the SMIL 2.0 features are present, and in RealPlayer 7 or 8 to ensure that backward-compatibility works. You will need a separate computer for each version of RealPlayer you test.

    View it now! (requirements for viewing this sample)
    This sample demonstrates a backward- compatible SMIL 2.0 file. With RealOne Player, a semi- transparent logo appears over the video. In RealPlayer 7 or 8, only the video appears.

Full SMIL File Switching

As noted in "Using a SMIL File as a Source", a SMIL file can use another SMIL file as a source clip. Combining this feature with switching gives you a powerful means for splitting your presentation into separate SMIL files. You can then avoid writing a single SMIL file with complex <switch> groups around its many elements. For example, your master SMIL file may look like this:

<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<body>
<switch>
<ref src="smilswitch_fr.smil" systemLanguage="fr"/>
<ref src="smilswitch_es.smil" systemLanguage="es"/>
<ref src="smilswitch_ja.smil" systemLanguage="ja"/>
<ref src="smilswitch_sv.smil" systemLanguage="sv"/>
<ref src="smilswitch_def.smil"/>
</switch>
</body>
</smil>

This main SMIL file defines no layout, title, author, or copyright. The body consists entirely of a <switch> group. The first SMIL file in the group plays only if the viewer's RealOne Player has French as its preferred language setting. The next three SMIL files play for viewers preferring Spanish, Japanese, or Swedish, respectively. The last file plays for all other viewers. Each referenced SMIL file defines its own layout, content, and timing, and may have additional <switch> groups to play different content if, for example, the viewer requests system captions.

View it now! (requirements for viewing this sample)
This sample displays a different video and related info page if your language preference is set to French, Spanish, Japanese, or Swedish through Tools>Preferences>Content.


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