Conditional Play
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.
Supported Functions
The expr tag content is an HTML-encoded XPath 1.0 expression or XPath 1.0 functions.
In addition to XPath 1.0, IAdea established some player-specific functions also date and compare functionally which were introduced in XPath 2.0. The prefix adapi- is used for this function-set.
Function | Description | Example |
---|---|---|
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.