How Does the endsync Attribute Work in SMIL?
The endsync attribute in Synchronized Multimedia
Integration Language (SMIL) controls the active duration and
synchronization semantics of a parallel container
(<par>). By defining whether the container finishes
when its first child ends, when all children finish, or when a specific
designated child completes, endsync resolves how concurrent
media tracks with differing durations interact within a single
timeline.
Purpose of the endsync Attribute
In SMIL, a <par> element groups multiple
multimedia elements—such as audio, video, text, and animations—to play
concurrently. Because different media items frequently have distinct
intrinsic or declared durations, the container requires explicit rules
to govern its endpoint.
When an explicit container duration (dur) or fixed
container end condition (end) is not supplied, the
endsync attribute dictates which child element's implicit
or explicit end triggers the end of the entire parallel container. Once
the selected condition is met, the container concludes, and any
currently playing sibling elements inside that container are forced to
terminate.
Supported Values and Semantics
The SMIL specification defines several standard values for the
endsync attribute:
endsync="last"(Default): The container ends when the last active child element reaches its natural or declared end. If one child lasts 5 seconds and another lasts 15 seconds, the container terminates at 15 seconds.endsync="first": The container ends immediately when the first child element finishes. Any remaining active child elements are immediately cut short and stopped.endsync="all": The container ends when all child elements have ended their active durations. In scenarios with simple static durations, this behaves similarly tolast, but it handles dynamically resolved endpoints where all streams must register completion.- **
endsync="Id-value"/endsync="id(...)":**The container synchronizes its ending to a specific child element referenced by its XMLid. Regardless of whether other siblings finish earlier or later, the container finishes exactly when the designated element concludes.
Interaction with Child Durations
The endsync evaluation takes place in real time during
presentation playback:
<par endsync="first">
<video id="mainVideo" src="clip.mp4" dur="10s" />
<audio id="bgMusic" src="music.mp3" dur="30s" />
</par>In this example, the audio track has a declared duration of 30
seconds, but the video lasts only 10 seconds. Because
endsync is set to first, the conclusion of
mainVideo at the 10-second mark causes the entire
<par> block to end, halting bgMusic
prematurely at 10 seconds.
Conversely, referencing an explicit ID allows critical elements to drive timeline progression:
<par endsync="masterAudio">
<video src="ambient.mp4" repeatCount="indefinite" />
<audio id="masterAudio" src="narration.mp3" dur="12s" />
</par>Even though the ambient background video is configured to repeat
indefinitely, the container terminates as soon as
masterAudio finishes its 12-second playback.
Precedence and Edge Cases
The behavior of endsync is subject to container-level
constraints:
- Explicit
duron<par>: If a<par>element defines its own explicitdur, that duration sets the maximum active timeline boundary unless overridden by an earlierendsynctrigger. - Explicit
endon<par>: A container-levelendattribute condition supersedes child completion events if the specified condition occurs first. - Zero or Indefinite Children: If all children are
indefinite and
endsync="last"is used, the container will run indefinitely until an external trigger stops it. Ifendsync="first"is used alongside at least one child with a finite duration, the container safely resolves at the end of that finite child.