How Does the
<par> Container Run Elements in SMIL?
The <par> (parallel) element in Synchronized
Multimedia Integration Language (SMIL) is a timing container designed to
execute multiple child media elements concurrently rather than
sequentially. While its default behavior initiates all child elements at
the exact same moment the container begins, developers can control start
times, offsets, end conditions, and synchronization rules through
specific timing attributes. This article explores the internal timing
model of <par>, detailing how child elements begin,
how container duration is determined, and how dynamic synchronization
affects playback.
The Basic Execution Model
In SMIL, the <par> element defines a temporal
grouping where the default start time of each child element is zero
relative to the container's start. When the <par>
container is activated, the playback engine immediately evaluates all
child elements (such as audio, video, images, or text) and begins
executing them simultaneously.
Unlike the <seq> (sequence) container, which waits
for the previous child to finish before triggering the next,
<par> allows media streams with overlapping durations
to play together in parallel.
<par>
<video src="presentation.mp4" />
<audio src="voiceover.mp3" />
<img src="slides.png" />
</par>In this basic configuration, the video, audio track, and slide image all initialize and display at the same instant.
Controlling Child Start Times and Offsets
Although child elements inside <par> share a
common timeline origin, they do not have to start simultaneously. The
begin attribute allows individual children to specify
temporal offsets or event-based triggers relative to the parent
container or sibling elements.
- Offset Timing: Specifying
begin="5s"delays an individual element's execution by five seconds after the<par>container starts. - Syncbase Timing: Specifying
begin="mediaA.begin+2s"ties an element's start to the activation of another element within the parallel group. - Event-Based Timing: Setting
begin="button.click"pauses execution until a specific interaction event occurs within the container's active lifecycle.
Container End
Behavior and the endsync Attribute
A critical aspect of <par> execution is
determining when the container itself ends. The overall duration of
<par> can be explicitly defined using the
dur attribute or determined implicitly by the lifespan of
its children via the endsync attribute.
The endsync attribute accepts several values that
dictate termination:
endsync="last"(Default): The<par>container remains active until the child element with the longest duration finishes playing. Shorter media streams finish and either freeze on their final frame or disappear, depending on theirfillattribute.endsync="first": The container ends as soon as any one of its child elements completes playback, immediately terminating all other active children.endsync="all": The container waits until every single child element has resolved its active duration.endsync="[ID]": The container terminates when a specific child element (identified by its XMLid) reaches the end of its duration.
Synchronization and Drift Management
When executing continuous media types like separate audio and video
tracks in parallel, clock drift can cause streams to fall out of sync.
SMIL manages this through the syncBehavior and
syncTolerance attributes applied to
<par> children:
syncBehavior="hard": Forces elements to maintain strict frame-by-frame synchronization, pausing or skipping frames if one stream lags behind the container clock.syncBehavior="soft": Allows a predefined tolerance window before attempting corrective synchronization actions.syncBehavior="locked": Couples the playback clock directly across all designated streams, ensuring collective pausing or seeking.
Through these combined timing primitives, the
<par> container provides a robust framework for
orchestrating complex, multi-layered multimedia presentations.