org.jvoicexml.xml.ssml
Class Audio

java.lang.Object
  extended by org.jvoicexml.xml.AbstractXmlNode
      extended by org.jvoicexml.xml.ssml.Audio
All Implemented Interfaces:
SsmlNode, VoiceXmlNode, XmlNode, XmlWritable, Node

public final class Audio
extends AbstractXmlNode
implements VoiceXmlNode

Audio can be played in any prompt. The audio content can be specified via a URI, and in VoiceXML it can also be in an audio variable previously recorded.

<prompt>
Your recorded greeting is
<audio expr="greeting"/> To rerecord, press 1.
To keep it, press pound.
To return to the main menu press star M.
To exit press star, star X.
</prompt>

The <audio> element can have alternate content in case the audio sample is not available:

<prompt>
<audio src="welcome.wav">
<emphasis>Welcome </emphasis> to the Voice Portal.
</audio>
</prompt>

If the audio file cannot be played (e.g. 'src' referencing or 'expr' evaluating to an invalid URI, a file with an unsupported format, etc), the content of the audio element is played instead. The content may include text, speech markup, or another audio element. If the audio file cannot be played and the content of the audio element is empty, no audio is played and no error event is thrown.

If <audio> contains an 'expr' attribute evaluating to ECMAScript undefined, then the element, including its alternate content, is ignored. This allows a developer to specify <audio> elements with dynamically assigned content which, if the element is not required, can be ignored by assigning its 'expr' a null value.

Version:
$Revision: 154 $

Copyright © 2005-2006 JVoiceXML group - http://jvoicexml.sourceforge.net/

Author:
Steve Doyle
See Also:
Form, Prompt

Field Summary
static String ATTRIBUTE_EXPR
          An ECMAScript expression which determines the source of the audio to be played.
static String ATTRIBUTE_FETCHHINT
          Defines when the interpreter context should retrieve content from the server. prefetch indicates a file may be downloaded when the page is loaded, whereas safe indicates a file that should only be downloaded when actually needed.
static String ATTRIBUTE_FETCHTIMEOUT
          The interval to wait for the content to be returned before throwing an error.badfetch event.
static String ATTRIBUTE_MAXAGE
          Indicates that the document is willing to use content whose age is no greater than the specified time in seconds.
static String ATTRIBUTE_MAXSTALE
          Indicates that the document is willing to use content that has exceeded its expiration time.
protected static ArrayList<String> ATTRIBUTE_NAMES
          Supported attribute names for this node.
static String ATTRIBUTE_SRC
          The URI of the audio prompt.
static String TAG_NAME
          Name of the tag.
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
Audio()
          Construct a new audio object without a node.
 
Method Summary
protected  boolean canContainChild(String tagName)
          Can the specified sub-tag be contained within this node?
 Collection<String> getAttributeNames()
          Returns a collection of permitted attribute names for the node.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 String getExpr()
          Retrieve the expr attribute.
 String getFetchhint()
          Retrieve the fetchhint attribute.
 String getFetchtimeout()
          Retrieve the fetchtimeout attribute.
 String getMaxage()
          Retrieve the maxage attribute.
 String getMaxstale()
          Retrieve the maxstale attribute.
 String getSrc()
          Retrieve the src attribute.
 String getTagName()
          Get the name of the tag for the derived node.
 XmlNode newInstance(Node n)
          Create a new instance for the given node.
 void setExpr(String expr)
          Set the expr attribute.
 void setFetchhint(String fetchhint)
          Set the fetchhint attribute.
 void setFetchtimeout(String fetchtimeout)
          Set the fetchtimeout attribute.
 void setMaxage(String maxage)
          Set the maxage attribute.
 void setMaxstale(String maxstale)
          Set the maxstale attribute.
 void setSrc(String src)
          Set the src attribute.
 
Methods inherited from class org.jvoicexml.xml.AbstractXmlNode
addChild, addChild, appendChild, cloneNode, compareDocumentPosition, getAttribute, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeFactory, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setNodeValue, setPrefix, setTextContent, setUserData, toString, writeChildrenXml, writeXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jvoicexml.xml.XmlNode
addChild, getAttribute, getChildNodes, getNode, setAttribute
 
Methods inherited from interface org.jvoicexml.xml.XmlWritable
writeChildrenXml, writeXml
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Field Detail

TAG_NAME

public static final String TAG_NAME
Name of the tag.

See Also:
Constant Field Values

ATTRIBUTE_SRC

public static final String ATTRIBUTE_SRC
The URI of the audio prompt.

See Also:
Constant Field Values

ATTRIBUTE_FETCHTIMEOUT

public static final String ATTRIBUTE_FETCHTIMEOUT
The interval to wait for the content to be returned before throwing an error.badfetch event. This defaults to the fetchtimeout property.

See Also:
Constant Field Values

ATTRIBUTE_FETCHHINT

public static final String ATTRIBUTE_FETCHHINT
Defines when the interpreter context should retrieve content from the server. prefetch indicates a file may be downloaded when the page is loaded, whereas safe indicates a file that should only be downloaded when actually needed. This defaults to the audiofetchhint property.

See Also:
Constant Field Values

ATTRIBUTE_MAXAGE

public static final String ATTRIBUTE_MAXAGE
Indicates that the document is willing to use content whose age is no greater than the specified time in seconds. The document is not willing to use stale content, unless maxstale is also provided. This defaults to the audiomaxage property.

See Also:
Constant Field Values

ATTRIBUTE_MAXSTALE

public static final String ATTRIBUTE_MAXSTALE
Indicates that the document is willing to use content that has exceeded its expiration time. If maxstale is assigned a value, then the document is willing to accept content that has exceeded its expiration time by no more than the specified number of seconds. This defaults to the audiomaxstale property.

See Also:
Constant Field Values

ATTRIBUTE_EXPR

public static final String ATTRIBUTE_EXPR
An ECMAScript expression which determines the source of the audio to be played. The expression may be either a reference to audio previously recorded with the <record/> item or evaluate to the URI of an audio resource to fetch.

See Also:
Constant Field Values

ATTRIBUTE_NAMES

protected static final ArrayList<String> ATTRIBUTE_NAMES
Supported attribute names for this node.

Constructor Detail

Audio

public Audio()
Construct a new audio object without a node.

This is necessary for the node factory.

See Also:
VoiceXmlNodeFactory
Method Detail

getTagName

public String getTagName()
Get the name of the tag for the derived node.

Specified by:
getTagName in interface XmlNode
Returns:
name of the tag.

newInstance

public XmlNode newInstance(Node n)
Create a new instance for the given node.

Each XmlNode can serve as a prototype in a XmlNodeFactory to produce a collection of child nodes. Factories can then use the prototype pattern to produce new nodes.

Specified by:
newInstance in interface XmlNode
Parameters:
n - The node to encapsulate.
Returns:
The new instance.
See Also:
XmlNodeFactory

getSrc

public String getSrc()
Retrieve the src attribute.

Returns:
Value of the src attribute.
See Also:
ATTRIBUTE_SRC

setSrc

public void setSrc(String src)
Set the src attribute.

Parameters:
src - Value of the src attribute.
See Also:
ATTRIBUTE_SRC

getFetchtimeout

public String getFetchtimeout()
Retrieve the fetchtimeout attribute.

Returns:
Value of the fetchtimeout attribute.
See Also:
ATTRIBUTE_FETCHTIMEOUT

setFetchtimeout

public void setFetchtimeout(String fetchtimeout)
Set the fetchtimeout attribute.

Parameters:
fetchtimeout - Value of the fetchtimeout attribute.
See Also:
ATTRIBUTE_FETCHTIMEOUT

getFetchhint

public String getFetchhint()
Retrieve the fetchhint attribute.

Returns:
Value of the fetchhint attribute.
See Also:
ATTRIBUTE_FETCHHINT

setFetchhint

public void setFetchhint(String fetchhint)
Set the fetchhint attribute.

Parameters:
fetchhint - Value of the fetchhint attribute.
See Also:
ATTRIBUTE_FETCHHINT

getMaxage

public String getMaxage()
Retrieve the maxage attribute.

Returns:
Value of the maxage attribute.
See Also:
ATTRIBUTE_MAXAGE

setMaxage

public void setMaxage(String maxage)
Set the maxage attribute.

Parameters:
maxage - Value of the maxage attribute.
See Also:
ATTRIBUTE_MAXAGE

getMaxstale

public String getMaxstale()
Retrieve the maxstale attribute.

Returns:
Value of the maxstale attribute.
See Also:
ATTRIBUTE_MAXSTALE

setMaxstale

public void setMaxstale(String maxstale)
Set the maxstale attribute.

Parameters:
maxstale - Value of the maxstale attribute.
See Also:
ATTRIBUTE_MAXSTALE

getExpr

public String getExpr()
Retrieve the expr attribute.

Returns:
Value of the expr attribute.
See Also:
ATTRIBUTE_EXPR

setExpr

public void setExpr(String expr)
Set the expr attribute.

Parameters:
expr - Value of the expr attribute.
See Also:
ATTRIBUTE_EXPR

canContainChild

protected boolean canContainChild(String tagName)
Can the specified sub-tag be contained within this node?

Specified by:
canContainChild in class AbstractXmlNode
Parameters:
tagName - Name of child.
Returns:
True if the sub-tag is allowed on this node.

getAttributeNames

public Collection<String> getAttributeNames()
Returns a collection of permitted attribute names for the node.

Specified by:
getAttributeNames in interface XmlNode
Overrides:
getAttributeNames in class AbstractXmlNode
Returns:
A collection of attribute names that are allowed for the node

getChildNodes

public final NodeList getChildNodes()
A NodeList that contains all children of this node.

Specified by:
getChildNodes in interface Node
Returns:
NodeList


Copyright © 2005-2007 JVoiceXML group.