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:
|smil-playerId()||Returns player UUID in lower case.||expr="adapi-compare(smil-playerId(),'player-uuid')"|
|smil-playerName()||Returns player name, which can be configured per player.||expr="adapi-compare(smil-playerName(),'Entrance')"|
|adapi-date()||Returns player's local date-time in ISO8601 format.||expr="adapi-compare(adapi-date(),'2010-01-01T00:00:00')<0"|
|adapi-gmdate()||Returns player's UTC date-time in ISO8601 format (ending in UTC indicator “Z”).||expr="adapi-compare(adapi-gmdate(),'2010-01-01T00:00:00Z')<0"|
|adapi-weekday()||Returns a number from 0 (Sunday) to 6 (Saturday) indicating player's local day-of-week.||expr="adapi-weekday()=1"|
|adapi-gmweekday()||Returns a number from 0 (Sunday) to 6 (Saturday) indicating player's UTC day-of-week.||expr="adapi-gmweekday()=1"|
|adapi-compare(string comp1, string comp2)||Returns -1 if comp1 is “less” than comp2 as a string, 0 if equal, 1 if “greater”.||expr="adapi-compare(adapi-date(),'2010-01-01T00:00:00')<0"|
Some more Examples
Even more sophisticated combinations are possible. ;-)
You can study a real-world example of conditional play here.