Important Audio Properties

There are many properties defined for the audio element in HTML5. We are going to focus on the following because they are the most useful for the applications we will build:


The total length, in seconds, of the sound represented by the audio object.


The current playing position, in seconds, of the playing audio file.


true or false: whether the audio clip should start playing at the beginning when currentTime reaches the duration.


true or false: whether the audio should start playing automatically when it has loaded.


true or false: Setting this to true silences the audio object regardless of volume settings.


true or false: Displays controls for an audio object in an HTML page. Controls will not display on the canvas unless they are created in HTML (for example, with a <div> overlay).


The volume level of the audio object; the value must be between 0 and 1.


true or false: whether the audio object is paused. Set with a call to the pause() function.


true or false. Set when an audio object has played through its entire duration.


URL to the source file for the audio object.


Specifies whether the media file should be loaded before the page is displayed. At the time of this writing, this property has not been implemented across all browsers.


To see which properties and events of the HTMLMediaObject are supported in which browsers, visit this site.

Get HTML5 Canvas, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.