Difference between revisions of "Conditional play"

From A-SMIL.org
Jump to: navigation, search
m
m
Line 8: Line 8:
 
<seq repeatCount="indefinite">
 
<seq repeatCount="indefinite">
 
   <video src="everyday.mpg" />
 
   <video src="everyday.mpg" />
   <video src="mondays.mpg" expr="1 = adapi-weekday()" />
+
   <video src="mondays.mpg" expr="1=adapi-weekday()" />
 
</seq>
 
</seq>
 
</source>
 
</source>

Revision as of 10:57, 3 August 2010

SMIL features the "expr" tag for defining conditions during which a media item is played. This is can be applied to

  • Limit the "validity period" within which a media file is licensed to play
  • Define items that only plays on certain days of the week

The general format to specifying a conditional play is by adding the "expr" tag to a media item, such as

<seq repeatCount="indefinite">
  <video src="everyday.mpg" />
  <video src="mondays.mpg" expr="1=adapi-weekday()" />
</seq>

In the sample code, item "everyday.mpg" is played every day the player is on, while item "mondays.mpg" is only played on Mondays.

Note that conditional play may break player optimizations designed to preload media objects for reducing gaps between items.

Supported Functions

The content of the expr tag is an HTML-encoded XPath expression. XPath functions are generally available, in addition to these following player-specific run-time conditional functions:

Function name Description Example
smil-playerId() Returns player UUID in lower case. This is a fixed value that cannot be changed. expr="adapi-compare(adapi-playerId(),'f1835d9f-be8f-4054-9e6c-123456789012')"
smil-playerName() Returns player name, which can be configured per player. expr="adapi-compare(adapi-playerName(),'Entrance screen')"
adapi-date() Returns player's local date-time in ISO8601 format. expr="adapi-compare(adapi-date(),'2010-01-01T00:00:00')&lt;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')&lt;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 Unicode string, 0 if equal, 1 if "greater". expr="adapi-compare(adapi-date(),'2010-01-01T00:00:00')&lt;0"

Related