Learning To SMILe - Spending Time (Page 5 of 8 )
SMIL also includes a fairly sophisticated timing model which allows you to control the timing and synchronization of media objects within the lifetime of the SMIL presentation. Basic timing support is made available via the "begin" and "dur" attributes, which allow you to specify a start time and duration respectively for the media. Values for these attributes may be specified in terms of time values or event notifications. Here's an example:
...
<img src="logo.jpg" alt="Image" region="alpha" begin="5s" />
...
In this case, the media will begin playing (in other words,
the image will be displayed) 5 seconds after the SMIL document has been loaded.
You can also specify a duration for the media:
...
<img src="logo.jpg" alt="Image" region="alpha" begin="5s" dur="10s" />
...
This sets up a clip of total duration 15 seconds, with the
image appearing 5 seconds into playback.
You can repeat an element via the "repeatCount" attribute, as follows:
...
<img src="logo.jpg" alt="Image" region="alpha" begin="5s" dur="10s" repeatCount="2" />
...
This would set up a clip of total duration 25 seconds, with
the image appearing 5 seconds into the clip.
It's also possible to explicitly terminate playback of a media clip before it gets to the end of its normal lifetime with SMIL's "end" attribute. Consider the following example, which demonstrates by ending a 10-second audio clip after 6 seconds.
...
<audio src="bg.wav" region="alpha" end="6s"/>
...
It's also possible to begin or end clips on specific events,
such as a mouse click or the start of any other media clip within the document. Consider the following example, which plays a video clip; the clip ends when the user clicks the mouse on it.
...
<video src="video.rm" region="alpha" end="click" />
...
A number of other options are available for event-based
timing in SMIL – take a look at the specification for a complete list, together with usage examples.
Next: Playing In Sync >>
More Multimedia Articles
More By icarus, (c) Melonfire