This appendix explains the structure of SMIL file, as well as the syntax rules for writing SMIL markup. Understanding these rules will help you to avoid the common problems that media authors encounter when developing SMIL presentations.
| View it now!
(requirements for viewing this sample)
This sample demonstrates the basic aspects of writing a SMIL 2.0 file. |
A SMIL file is a simple text file that you can create with any text editor. As
with a Ram file, make sure that you can save your output as plain text. Your
SMIL file should have a simple name without spaces, and end with the
extension .smil, as in my_smilfile.smil.
SMIL tags that come in pairs follow this form:
< |
There are three basic parts to these SMIL tags:
If you're familiar with HTML, you know that browsers often let you be sloppy
with end tags. For example, paragraphs in HTML should come between <p>
and </p> tags, but most browsers allow you to leave out the closing </p> tag.
SMIL doesn't let you get away with sloppiness, though, and you'll get an error
message if you leave out a closing tag.
If the tag is not part of a tag pair, as in <head> and </head>, it must close with
a forward slash, as in <meta/>. The forward slash tells RealPlayer that
everything it needs to know about this tag is contained within the tag's angle
brackets, and it doesn't need to hunt for a closing tag. In general, tag pairs
create sections, such as the header section or body section, while single tags
describe specific actions, such as "display this title," or "play this video clip."
Tag names, attributes, and many values are case-sensitive. This is another area
where SMIL, unlike HTML, is strict. In HTML, for example, a paragraph tag
can be <p> or <P>. But in SMIL, the <smil> tag cannot be <SMIL>, <Smil>, <smIL>,
or any variation except entirely lowercase. Just make sure that you write tags
and attributes exactly as they appear in this guide.
Any SMIL tag can have an ID in the form id="value". Some SMIL tags require
IDs. For example, each region in the layout requires an ID that you use to
assign clips to play in the region. For other tags, IDs are optional depending
on whether another SMIL element interacts with that tag. The following are
rules and suggestions that apply to the IDs of all SMIL tags:
<region/> tags, for example, each tag must have a unique ID. No <region/> tag can have the same ID as a <video/> tag, for instance.id="videoregion" and id="videoRegion" are different, for example. It is a good idea to follow a consistent practice, such as always making IDs lowercase.videoregion, video-region, or video_region.id="video3" as an ID, but not id="3video".region for all region IDs, for example.The first and last lines of a SMIL 2.0 file for RealPlayer are these:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language" |
The <smil> tag has one long, necessary attribute:
<smil |
This attribute indicates that the file contains SMIL 2.0 markup. If you leave
this attribute out and use just the tag name (<smil>), you're defining a SMIL
1.0 file, and many of the features described in this guide won't work. In other
words, you must include this attribute and value exactly as shown above for a
SMIL 2.0 file to work.
| Note: Although the SMIL 2.0 and RealNetworks extension namespaces are valid HTTP URLs (you can open them in your browser), RealPlayer does not request these Web pages when it plays a SMIL 2.0 file. |
To use SMIL 2.0 features customized for RealPlayer, you need to include the
RealNetworks namespace in the <smil> tag:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language" |
Customized attributes such as rn:sendTo must share the rn: prefix used by this
namespace. Although you do not have to declare this namespace if you do not
use the customized attributes, it is safe to include this namespace in any SMIL
2.0 file, even those played by SMIL-based players other than RealPlayer. If a
SMIL-based player does not recognize a customized namespace and its
associated attributes, it simply ignores them.
In a SMIL file, a header section typically follows the <smil> tag. The header
section falls between <head> and </head> tags. Unlike the <smil> tag, the <head>
tag never includes attributes:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language" |
The body section is the companion to the header section, following it in the
SMIL markup. Together, the body and header define all of your presentation
features. Whereas the header describes the presentation's form, the body
delivers the content. Like the header section, the body section has a start tag
and an end tag, <body> and </body>, that do not take any attributes:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language" |
In the examples in this guide, each tag starts on a new line, and the entire file uses indentation, which is highly recommended for all SMIL markup. For example, the first lines of a SMIL file might look like this:
<smil xmlns="http://www.w3.org/2001/SMIL20/Language"> |
Each line is indented from the preceding line to indicate that the new tag is
part of the preceding section. The <meta/> tag is part of the <head> section,
and the <head> section is part of the <smil> section.
Savvy authors always indent their markup to clarify the file's organization, typically pressing Tab once for each level of indentation. The only purpose for this is to help you, and anyone else reading your file, to understand how the file works. RealPlayer doesn't care about tabs and line returns, though. It has no problem figuring out how the following file works, but can you say the same?
<smil xmlns="http://www.w3.org/2001/SMIL20/Language"><head><meta |
In a SMIL file, you can add a comment like the following:
<!-- The following clips play in sequence. --> |
Note that this tag does not require a closing slash. If you know HTML, you've probably guessed why this is: this isn't a SMIL tag at all. This is an HTML- style comment tag. This tag is so widely used in HTML that SMIL adopted it wholesale.
As with indentation, comment tags don't affect your presentation. RealPlayer ignores them, and their only purpose is to annotate your file. Even with indentation, complex SMIL files can be hard to figure out. Comments let you describe what's going on in the file, and can be extremely helpful for explaining markup to others, or even reminding yourself of how the file works. You can even comment out whole sections of SMIL markup if you don't want RealPlayer to play that section.
Note, though, that the hyphens in a comment tag aren't decoration. The comment must start with these four characters:
<!-- |
and end with these three characters:
--> |
Between these begin and end marks, the comment can be as long as you like. You cannot put one comment inside another comment, though.
<smil> tag must declare the SMIL 2.0 namespace:<smil xmlns="http://www.w3.org/2001/SMIL20/Language"> |
rn: prefix, as in rn:sendTo. Using these attributes requires that you also declare the RealNetworks customizations namespace in the <smil> tag:<smil xmlns="http://www.w3.org/2001/SMIL20/Language" |
<head> and </head> tags is optional, though highly recommended.<body> and </body> tags, is required.<body> and </body>, or must close with a forward slash, as in <audio/>.id attribute values within a SMIL file must be unique. An id value cannot start with a number.<!-- This is a comment. --> |
|
|
©2002, 2004 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. |