<audio>

Plays the media file at the specified location.

Syntax

<audio
    src = "URI"
    expr = "CDATA"
    fetchhint = "{prefetch | safe}"
    fetchtimeout = "CDATA"
    maxage = "CDATA"
    maxstale = "CDATA"
    offset = "CDATA"
    offsetexpr = "CDATA"
    type = "CDATA"
/>

Attributes

Attribute

Data Type

Required?

Default

Description

expr

CDATA

no

NA

ECMAScript expression that evaluates to the URI of the media file. Programmable Media Platform proprietary. Use the v_ovl_def parameter following the media file to specify:

  • a URI (in http:// or file:/// format) to an XML file that defines a text overlay or image overlay.

  • an XML string that defines a text overlay or image overlay inline.

fetchhint

{prefetch | safe}

no

NA

Specifies when the VoiceXML Interpreter context should retrieve content from the server. Valid values:

  • prefetch = Fetch the resource when the page is loaded.

  • safe = Fetch the resource when it is specifically called by the application.

fetchtimeout

CDATA

no

NA

Interval to wait for the content to be returned before throwing an error.badfetch event. Use s for seconds (for example, 1s) and ms for milliseconds (for example, 1ms).

maxage

CDATA

no

NA

Maximum acceptable age, in seconds, of a resource being fetched from the cache. Setting maxage to 0 means that a cached version is never considered fresh. If no maxage or maxstale values are set, the VoiceXML Interpreter:

  • Uses the cached resource, if the resource remains in the cache.

  • Performs a normal fetch, if the resource is not in the cache.

maxstale

CDATA

no

NA

Maximum acceptable staleness, in seconds, of the resource being fetched, if the fetched resource is cached and expired.

offset

CDATA

no

NA

Programmable Media Platform proprietary. The offset (in s or ms) at which to play the media file. This attribute is supported for:

  • HTTP or local files that reference a 3GP file

  • HTTP or local audio-only files

  • Audio-only files streamed by an RTSP server

  • Video files streamed by an RTSP server

The behavior of the offset attribute for HTTP or local files that reference a 3GP video file differs, depending on the presence of a sync point table and a matching I-frame. For information, see Details.

Note: The offset attribute is not supported for live RTSP presentations.

offsetexpr

CDATA

no

NA

An ECMAScript expression that evaluates to the offset. This can be used in conjunction with the lastresult$.bargeintime variable to let the application play a media file from the point at which the user barged in, and not have to restart the media file. This is especially useful for long media files.

src

URI

no

NA

URI of the media file. Use the v_ovl_def parameter following the media file to specify:

  • a URI (in http:// or file:/// format) to an XML file that defines a text overlay or image overlay.

  • an XML string that defines a text overlay or image overlay inline.

type

CDATA

no

NA

Preferred media type of the requested resource. This can differ from the actual media type of the resource. The VoiceXML Interpreter currently ignores this attribute, determining the media type during HTTP content negotiation or content introspection.

Details

The <audio> element can contain child content (alternate content) that is played if the media file specified by the src or expr attributes is either not found or cannot be played. The <audio> element can reference an HTTP, file, builtin, or RTSP URI in its src attribute. For example:

Valid source file types are:

The offset attribute works as follows for HTTP or local files that reference 3GP video files:

If the Referenced 3GP Video File...

And...

Then the VoiceXML Interpreter...

Contains a sync point table.

There is an I-frame that corresponds to the specified offset.

Plays the file from that I-frame.

 

The specified offset does not match an I-frame.

Plays the file from the next I-frame after the specified offset.

 

There is no next I-frame.

Does not play the file.

Does not contain a sync point table.

NA

Ignores the offset attribute and plays the file from the beginning.

Parents

<audio>, <block><catch>, <choice>, <enumerate><error>, <field>, <filled>, <foreach>, <help>, <if>, <initial>, <media>, <menu>, <noinput>, <nomatch>, <object>, <prompt>, <record>, <subdialog>, <transfer>

Children

<audio>, <break>, <desc>, <emphasis>, <enumerate>, <mark>, <media>, <p>, <phoneme>, <prompt>, <prosody>, <s>, <say-as>, <sub>, <value>, <voice>

Examples

The following example plays a .wav file:

<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
    <form>
        <block>
            <prompt>
                <audio src="../audio/test.wav" maxage="0"/>
            </prompt>
            <prompt>
                <audio src="http://www.webserver.com/doesNotExist.wav"
                    fetchtimeout="1s">
                    Audio does not exist
                </audio>

            </prompt>
        </block>
    </form>
</vxml>

The following example plays a .3gp file:

<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
    <form>
        <block>
            <prompt>
                <audio src="../video/test.3gp" maxage="0"/>
            </prompt>
            <prompt>
                <audio src="http://www.vision.com/doesNotExist.3gp"
                    fetchtimeout="1s">
                </audio>

            </prompt>
        </block>
    </form>
</vxml>

The following example plays an RTSP video stream using an offset.

<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
    <property name="inputmodes" value="dtmf"/>
    <var name="nAbsOffsetMS" expr="0"/>
    <form>
        <field name="VCRControl" type="digits?length=1">
            <prompt>
                <audio src="rtsp://www.example.org:554/3gp/myfile.3gp"
                    offsetexpr="nAbsOffsetMS + 'ms'"/>

            </prompt>
            <filled>
                <script>
                    // Determine the new offset based in the input
                    var nRelOffsetMS = 0;
                    nRelOffsetMS = (0 == VCRControl) ? -10000 : 10000;
                    nAbsOffsetMS = nAbsOffsetMS + lastresult$.bargeintime + nRelOffsetMS;
                    if (nAbsOffsetMS &lt; 0) nAbsOffsetMS = 0;
                </script>
                <clear/>
            </filled>
        </field>
    </form>
</vxml>

See Also

<prompt>