Easy Tutorial
❮ Prop Img Longdesc Prop Style Columnrulecolor ❯

HTML DOM Audio Object


Audio Object

The Audio object represents the HTML <audio> element.

Accessing the Audio Object

You can access the <audio> element using getElementById():

Creating an Audio Object

You can create an <audio> element using the document.createElement() method:

Audio Object Properties

Property Description
audioTracks Returns an AudioTrackList object representing the available audio tracks
autoplay Sets or returns whether the audio should start playing as soon as it is loaded
buffered Returns a TimeRanges object representing the buffered parts of the audio
controller Returns a MediaController object representing the current media controller of the audio
controls Sets or returns whether the audio should display controls (such as play/pause, etc.)
crossOrigin Sets or returns the CORS settings of the audio
currentSrc Returns the URL of the current audio
currentTime Sets or returns the current playback position in the audio (in seconds)
defaultMuted Sets or returns whether the audio should be muted by default
defaultPlaybackRate Sets or returns the default playback speed of the audio
duration Returns the length of the current audio (in seconds)
ended Returns whether the playback of the audio has ended
error Returns a MediaError object representing the error state of the audio
loop Sets or returns whether the audio should start over again when finished
mediaGroup Sets or returns the group the audio belongs to (used to link multiple audio elements)
muted Sets or returns whether the audio is muted
networkState Returns the current network state of the audio
paused Sets or returns whether the audio is paused
playbackRate Sets or returns the speed of the audio playback
played Returns a TimeRanges object representing the played parts of the audio
preload Sets or returns whether the audio should be loaded when the page loads
readyState Returns the current ready state of the audio
seekable Returns a TimeRanges object representing the seekable parts of the audio
seeking Returns whether the user is currently seeking in the audio
src Sets or returns the current source of the audio element
textTracks Returns a TextTrackList object representing the available text tracks
volume Sets or returns the volume of the audio

Audio Object Methods

Method Description
addTextTrack() Adds a new text track to the audio
canPlayType() Checks whether the browser can play the specified audio type
fastSeek() Specifies the playback time in the audio player.
getStartDate() Returns a new Date object representing the current timeline offset
load() Reloads the audio element
play() Starts playing the audio
pause() Pauses the currently playing audio

Standard Properties and Events

The Audio object also supports standard properties and events.


Related Articles

HTML Tutorial: HTML5 audio

HTML Reference: HTML <audio> Tag

HTML Audio/Video DOM Reference: HTML Audio/Video

❮ Prop Img Longdesc Prop Style Columnrulecolor ❯