HTML and CSS Reference
n Note To test the Flash or Silverlight fallback scheme, you need a browser version that doesn't support HTML5
<audio> and <video> elements.
Programming with the Audio and Video APIs
So far, you've been using static <audio> and <video> elements to play audio and video files. HTML5 also
what you can configure, Table 3-3 shows a list of the properties, methods, and events of the <audio> and
<video> DOM elements that you have at your disposal. Note that Table 3-3 lists only the commonly used
members of <audio> and <video> .
n Note You can browse all the available members of the <audio> and <video> elements at www.w3schools.
com . This web site also provides a good reference for the other HTML5 tags, properties, methods, and events.
Table 3-3. Properties, Methods, and Events of the <audio> and <video> DOM Elements
Method / Event
The canPlayType() method returns true/false depending on whether a
particular MIME type can be played by the <audio> or <video> element.
The currentTime property indicates the current time instance of a
media file in seconds.
The duration attribute returns duration of the media file being played
in milliseconds. This property returns correct value only if the
metadata of the file is available at the time of reading the property.
The ended event is raised when the media file is played completely.
The pause event is raised when a media file is paused.
The pause() method pauses a media file being played.
The play event is raised when a media file is played.
The play() method plays a media file specified by the src property.
The playbackRate property governs the speed at which a media file is
played. Default is 1 which means normal speed. Value of 2 means twice
the normal speed and so on.
The playing event is raised when the media file is ready to play.
The src property indicates a URL of the media file to be played.
The timeupdate event is raised when the current playback position is
The volume property indicates the volume level of the audio/video
player. Possible values are between 0 and 1, 1 being maximum volume
and 0 being mute.
The volumechange event is raised when the volume of a media file
being played is changed.