SMIL: The Essentials
SMIL features the
expr attribute. We use this to define conditions for media playback. This is a powerful feature. Especially when you combine this with triggers.
- Defining a “validity period” for playback of licensed media
- Set SMIL elements for displaying on certain weekdays
- Ability to a micro adjustment playback via ID or other meta-data
A simple Example
The general format to specifying a conditional play is by adding the
expr attribute to a media item. When the given expression equals to “true” the associated item is played.
btw: This also works with playlist container.
The expr tag content is an HTML-encoded XPath expression or XPath functions.
In addition to these, IAdea established in a-smil.org following player-specific functions with adapi-prefix:
||Returns player UUID in lower case.
||Returns player name, which can be configured per player.
||Returns player's local date-time in ISO8601 format.
||Returns player's UTC date-time in ISO8601 format (ending in UTC indicator “Z”).
||Returns a number from 0 (Sunday) to 6 (Saturday) indicating player's local day-of-week.
||Returns a number from 0 (Sunday) to 6 (Saturday) indicating player's UTC day-of-week.
|adapi-compare(string comp1, string comp2)
||Returns -1 if comp1 is “less” than comp2 as a string, 0 if equal, 1 if “greater”.
Some more Examples
Even more sophisticated combinations are possible. ;-)
You can study a real-world example of conditional play here.