SMIL supports 3 container types
- Sequential
- Parallel
- Exclusive
Sequential Playlist
The sequential playlist is the simplest form of playlists in SMIL. In a sequential playlist, media objects are played in the order they are listed in the SMIL file. One media object starts playing after the one ends.
<seq repeatCount="indefinite"/>
<video src="video1.mkv" />
<img src="image.png" dur="5s" />
<seq/>
Another great feature of SMIL is the option to nest container.
<seq repeatCount="indefinite"/>
<video src="video1.mkv" />
<seq repeatCount="3"/>
<img src="image1.jpg" dur="5s" />
<img src="image2.jpg" dur="5s" />
<seq/>
<seq/>
You can find a simple seq sample to study here, here, and here
Parallele Playlist
The SMIL parallel playlist is a list of media objects that start playback simultaneously. Illustration of using the parallel playlist for multi-zone effects is located in the section on Layout. Children of the parallel playlist can be specified to start at a specific time defined by the player's real-time clock. See the section on trigger for details.
<par>
<seq repeatCount="indefinite">
<img src="pic1.jpg" dur="5s" />
<img src="pic2.jpg" dur="5s" />
<img src="pic3.jpg" dur="5s" />
</seq>
<audio src="music.mp3" repeatCount="indefinite" />
</par>
The parallel schedule has two children: a sequential playlist containing three images, and a single audio media object. The sequential playlist and the audio object start simultaneously, like a slide show, while music plays in the background.
You can find a real world with a simple multiple screen layout par samples to study here
Exclusive Playlist
This is the most interesting, but also most complicated container. It allows only one of its children to play at the same time. The start of one media object causes the currently playing item to either pause or stop. The priorityClass tag further defines interrupt priorities and behavior (pause, defer, never, or stop) of media objects when interrupts occur. The starting of a media object may be triggered by an event such as a key press, mouse click, touch, or a time, as the following sample code illustrates.
The peer-attribute describes the interrupted behavior of the priorityClass children.
Stop behavior
Stop means that a higher element stops the lower element.
<excl>
<priorityClass peers="stop">
<img src="0002.jpg" begin="1s" dur="1s" />
<img src="0001.jpg" begin="0s" dur="10s" />
</priorityClass>
</excl>
The attribute beginning will be discussed during the lesson trigger in more detail. You need to imagine a timeline. It starts on 0s with image 1 which should play the 10s. But it will be interrupted by 001 after 1s because 1 has a higher priority in the priority class.
Peer default
<excl>
<img src="0002.jpg" begin="1s" dur="1s" />
<img src="0001.jpg" begin="0s" dur="10s" />
</excl>
You can skip the priorityClass-tags if you use only one priority. If you have two priorities, it is necessary to use the priorityClass two times; otherwise this is an error. As the default behavior for peer is stop, we get the same results as above.
A more complex real-world example to study the peer stop behavior
Pause behavior
Pause causes a higher element to pause the lower element. The paused element enters a waiting queue. After the higher element is finished, the lower element plays again for the remaining time of his duration.
<excl>
<priorityClass peers="pause">
<img src="0002.jpg" begin="1s" dur="1s" />
<img src="0001.jpg" begin="0s" dur="10s" />
</priorityClass>
</excl>
This timeline starts on 0s with image 001 and will again be interrupted by 001 after 1s because 1 has a higher priority in the priority class. But because we set pause as a peer after the end of 002, it jumps back to 002 and plays for a rest time of 9 s.
Study pause behavior
Defer behavior
Defer describes what happened when a lower element tries to interrupt a higher element. In this case, the lower element will take place in a waiting queue until the higher element finished.<excl>
<priorityClass peers="defer">
<img src="0001.jpg" begin="0s" dur="10s" />
<img src="0002.jpg" begin="1s" dur="2s" />
</priorityClass>
</excl>
This timeline starts on 0s with image 001 and after one second image 002 tries to start. But as image 002 has a lower priority, it will enter in wait state. Nine seconds later, when 001 is finished, 002 starts to display for two seconds.
Study the defer behavior with this example
Never behavior
A lower element stops when it attempts to start during an active duration of his higher sibling.
<excl>
<priorityClass peers="never">
<img src="0001.jpg" begin="0s" dur="10s" />
<img src="0002.jpg" begin="1s" dur="2s" />
</priorityClass>
</excl>
This timeline starts on 0 s with image 001, and after one-second lower prioritized image 002 tries to start. In this case, nothing happens and image 002 is ignored.
Study the never behavior
The Higher Attribute
The attribute higher describe, what happened when an item from, a higher priorityClass group interrupts an element from a lower priorityClass. There are two options: pause (default) and stop.<excl>
<priorityClass">
<img src="0001.jpg" begin="1s" dur="10s" />
</priorityClass>
<priorityClass higher="stop">
<img src="0003.jpg" begin="0s" dur="2s" />
<img src="0004.jpg" begin="2s" dur="2s" />
</priorityClass>
</excl>
This is similar to the stop behavior in peer, but this control two or more groups of elements in priorityClass.
Study examples for Higher-attributes
The Lower Attribute
The attribute lower describes, what happened when an item of an element from a lower priorityClass tries to interrupt a higher priority. There are two options: defer (default) and never.<excl>
<priorityClass lower="defer">
<img src="0001.jpg" begin="0s" dur="10s" />
<img src="0002.jpg" begin="10s" dur="1s" />
</priorityClass>
<priorityClass>
<img src="0003.jpg" begin="1s" dur="2s" />
</priorityClass>
</excl>
This is also similar to the deferred behavior in peer. Image 1 starts three attempts to interrupt, bus as in lower priority it moves to a waiting queue and starts player after the finish of image 2. The higher priority has a duration of 12 seconds.
Study examples for Lower-attributes
Generic Container Attributes
In this starter tutorial, the repeatCount attribute is relevant for playlist containers and media objects.
Repeat Count
The attribute repeatCounts controls how often the media or container can be repeated. There are two values possible:
- indefinite: In this context, it means endless.
- numeric value: A decimal integer number greater than 0. Some SMIL-player also supports floating-point numeric values like 2.5.