Playback of memory audio

Support in HbbTV

Available since: HbbTV 1.0 (ETSI TS 102 796 V1.1.1, OIPF DAE V1.1)

This section describes how an A/V Control object can be used for the playback of audio from memory.

Usage of CE-HTML tags

The A/V Control object SHALL be used to play audio clips from memory.  The value of the A/V Control object’s type attribute SHALL be set to one of the values defined in section 8.2.1 of [OIPF_MEDIA2]. The <object> element representing the A/V Control object MAY contain <param> elements to set the value of parameters affecting the playback of the clip,  For audio from memory, valid parameters are:

  • cache – a value of “true” indicates that the audio clip should be played from memory.  This parameter SHALL be included for all clips to be played from memory.  For formats which can not be played from memory, or for values of the parameter other than “true”, this parameter SHALL have no effect. The default value of this parameter SHALL be “false”.
  • loop – indicates the number of times the audio clip SHALL be played when play() is called. The value SHALL be positive integers or the string “infinite”, which SHALL play the audio clip continuously until stop() is called or the data property is set to null. The default value of this parameter SHALL be “1”.

Simultaneous playback of multiple audio clips from memory, or simultaneous playback of audio clips from memory and streaming audio or video presentation SHALL follow the behaviour described in section 4.4.5.

Usage of the DOM interface

For A/V Control objects used to play audio from memory, the following properties and methods SHALL be supported:

  • The properties data, playState, error and onPlayStateChange, as defined in Req. 5.7.1.f of [CEA-2014-A].
  • The methods play() and stop(), as defined in Req. 5.7.1.f of [CEA-2014-A]. 

When the play() method is called, if a <param> element as described above is present where the cache parameter is set to the value “true”, the OITF SHALL:

  • attempt to pre-load the audio clip specified by the value of its data property and play the audio clip from memory.  If the terminal cannot pre-load the audio clip due to insufficient memory, the terminal SHALL play the clip as streaming audio.
  • attempt to retain the audio clip in its cache once playback has finished, until the A/V Control object’s data property is modified or the A/V Control object is destroyed.

If the A/V Control object’s data property refers to a file in a format other than those listed in section 8.2.1 of [OIPF_MEDIA2], the A/V Control object SHALL NOT attempt to play the file from memory.

The <param> element as defined in section 7.14.10.2 of this document SHALL be made accessible through a DOM HTMLParamElement object.

Example usage (Informative)

The following HTML document shows an example of a script to start the playback of memory audio:

<head>
 :
<script type="text/javascript">
     function startBGM() {
         document.getElementById("aid1").play(1);
     }
     :
</script>
</head>
<body>
<object type="audio/mp4" id="aid1" data="http://www.avsource.com/audio/bgm.aac">
    <param name="cache" value="true"/>
    <param name="loop" value="infinite"/>
</object>
 :
<div id="btn1" onclick="startBGM()"><img src="start1.gif"/></div>
 :
</body>

The following HTML document shows an example of a script to stop the playback of memory audio:

<head>
  :
<script type="text/javascript">
     function stopBGM() {
         document.getElementById("aid1").stop();
     }
  :
</script>
</head>
<body>
<object type="audio/mp4" id="aid1" data="http://www.avsource.com/audio/bgm.aac">
<param name="cache" value="true"/>
<param name="loop" value="infinite"/>
</object>
 :
<div id="btn2" onclick="stopBGM()"><img src="stop1.gif"/></div>
  :
</body>