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.
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. |
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> |
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.
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:
Any RealONE Player will choose an option that does not include a test attribute. Hence, any RealONE Player that did not choose an option with a test attribute will choose the option without the test attribute.
<switch> group.RealONE Player always evaluates options in the order they are listed, playing the first suitable option it finds. If you list a default option before options that includes test attributes, no RealONE Player will ever evaluate the test attributes of the options following the default option.
The following example modifies the preceding example to add an English- language clip as the default choice:
<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.
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> |
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> |
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> |
The following table lists the test attributes available for switching. These attributes are described in detail in the remainder of this chapter.
| Attribute | Value | Tests For | Reference |
|---|---|---|---|
systemAudioDesc |
on|off |
audio descriptions preference | click here |
systemBitrate |
bits_per_second |
total available bandwidth | click here |
systemCaptions |
on|off |
captions preference | 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 |
systemScreenDepth |
1|4|8|24|32 |
monitor color bit depth | click here |
systemScreenSize |
heightXwidth |
monitor size | click here |
<switch> tag must fall within the <head> or <body> section of your SMIL file. In other words, the <smil>, <head>, or <body> tags cannot fall within a <switch> tag.<switch> tag in the header section to let RealONE Player choose between alternative layouts. See "Example 3: Resizing the Media Window for Captions" for an example of modifying the layout to accommodate system captions.<switch> tag to switch between alternative <seq>, <par>, or <excl> groups. In these cases, you add the test attributes to the group tags instead of to the clip source tags.<switch> tags to achieve the same results. See "Switching with Multiple Attributes" for examples of how to use both methods.<area/> tags inside the clip source tags, rather than with <a> and </a> tags around the clip tags. Add the test attribute to the clip tag, as shown here:<video src="video1.rm" systemLanguage="fr" ...> |
For More Information:
For more on the <area/> tag, see "Using
the <area/> Tag".
|
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
and its evaluation of the systemLanguage values:
<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.
| View it now!
(requirements for viewing this sample)
This sample demonstrates language switching . A different number (1 through 5) appears if you set your RealONE Player language preference to French, German, Spanish, Japanese, or Korean. Number 6 is the default, which appears for any other language preference. |
Appendix G 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:
<switch/> group. For example, a RealONE Player with a preference for Mexican Spanish plays clips designated with es-mx or es. If a clip with the value es comes first, RealPayer does not continue to evaluate options to determine if the es-mx option is present.es. If the only choices are es-mx and es-pr, for instance, this RealONE Player does not choose either option.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> |
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.
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:
original.rm)dubbed.rm)titled.rm)You can use systemOverdubOrSubtitle along with systemLanguage in a <switch>
group as shown in the following example:
<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.
|
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> |
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> |
| For More Information: The table "Maximum Streaming Rates" gives bandwidth guidelines for various network connections. |
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:
<switch> tag.<switch> tag when combining a SureStream clip with other clips encoded for single bandwidths. The SureStream clip is always used, but the <switch> group gives RealONE Player options for other clips. The following example illustrates a RealAudio SureStream clip and a choice between two RealPix presentations built for different bandwidths:<par> |
RealONE Players that have at least 47,000 bits per second of available bandwidth choose slideshow1.rp. If this slideshow takes 25 Kbps, for example, these RealONE Players pick a SureStream track from soundtrack.rm that requires 22 Kbps or less of bandwidth. RealONE Players with between 47,000 and 20,000 bps of available bandwidth choose slideshow2.rp, along with a SureStream track that keeps the combined clips under 20 Kbps.
| For More Information: For more on SureStream, see "SureStream RealAudio and RealVideo". Refer to "Step 3: Develop a Bandwidth Strategy" for information on targeting certain network connection speeds. |
RealONE Player users who are sight- or hearing-impaired can set an
accessibility preference that gives them audio descriptions or captions,
respectively, 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:
video.rm).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.
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> |
| For More Information: See "Displaying System Captions Using RealText" for an example of using RealText to provide system captions. |
Several <switch> tag attributessystemCPU, systemOperatingSystem,
systemScreenSize, and systemScreenDepthlet 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.
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.
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.
|
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.
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.
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:
| 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.
|
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.
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. Choose Sample Files from the pull-down menu to view all the playable sample files included in this chapter.
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:
In the following example, the first two RealAudio clips have two test attributes
eachone 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> |
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> |
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.
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> |
| For More Information: Target bit rates are listed in the table "Maximum Streaming Rates". |
As the section "Enhancing Presentation Accessibility" explains, you can use
the systemCaptions attribute to display captions for hearing-impaired viewers.
The following examples demonstrate various ways to display RealText
captions coordinated with an audio track.
Note:
You can use any means to provide captions. The
systemCaptions="on" attribute simply tells RealONE Player to
play a certain clip if the viewer has set the captions preference.
There are no requirements for what type of clip to use for
captions, though.
|
| For More Information: Chapter 6 explains how to write and time a RealText clip. See Chapter 11 for information about layouts. |
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 transparent
background. 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> |
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> |
| 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. |
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> |
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> |
| 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. |
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> |
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> |
| 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 main media window and displays captions if the captions preference is turned on. |
|
|
©2001 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. |