What Does endsync Do in SMIL?

The endsync attribute in Synchronized Multimedia Integration Language (SMIL) controls when a parallel time container (<par>) ends its active duration relative to the lifespans of its child elements. By setting endsync to first, last, or all, developers determine whether a composite multimedia presentation cuts short as soon as the earliest track finishes, waits for a specific element to conclude, or continues until every track has naturally completed.

The Role of endsync in SMIL

In SMIL, the <par> container plays multiple media elements—such as video, audio, text, and animations—simultaneously. Because each child element often has a different duration, the container needs a rule to determine when to conclude playback.

The endsync attribute specifies the synchronization condition that dictates the end of the <par> container. The three core values—first, last, and all—handle child lifespans differently.

endsync="first"

When endsync is set to first, the <par> container ends its playback as soon as the first child element reaches the end of its active duration.

<par endsync="first">
  <!-- Plays for 5 seconds; container ends here, cutting the video short -->
  <audio src="short_audio.mp3" dur="5s" />
  <video src="long_video.mp4" dur="20s" />
</par>

endsync="last"

When endsync is set to last, the <par> container ends when the last scheduled child element with an explicit duration finishes its active duration.

<par endsync="last">
  <!-- Container ends at 15 seconds, ignoring the indefinite loop -->
  <audio src="speech.mp3" dur="15s" />
  <img src="background_animation.svg" dur="indefinite" />
</par>

endsync="all"

When endsync is set to all (which is often the default behavior for <par> containers), the container waits until every single child element has completed its active duration.

<par endsync="all">
  <!-- Container waits until the full 30 seconds elapse -->
  <audio src="background.mp3" dur="30s" />
  <video src="presentation.mp4" dur="20s" />
  <text src="captions.html" dur="10s" />
</par>

Summary Comparison

Value When the Container Ends Behavior with Indefinite Elements
first As soon as the shortest child finishes. Truncates any longer media instantly.
last When the last scheduled/finite child finishes. Ignores indefinite children and closes when fixed media ends.
all When every child element has finished. Will run indefinitely if any child has an indefinite duration.