Latest web development tutorials

HTML DOM Audio Object

Audio Object

Audio objects in the new HTML5. .

Audio object represents the HTML <audio> element.

Access Audio Object

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

var x = document.getElementById("myAudio"); 尝试一下

Creating Audio Objects

You can use document.createElement () method to create the <audio> element:

var x = document.createElement("AUDIO"); 尝试一下

Audio Object Properties

Attributes description
audioTracks Back AudioTrackList objects available audio tracks representation
autoplay Sets or returns whether to play audio immediately after loading is completed
buffered It returns the audio portion of the object buffer has TimeRanges
controller Returns current audio MediaController objects representing the media control
controls Sets or returns whether the audio display controls (such as play / pause, etc.)
crossOrigin Sets or returns the audio settings CORS
currentSrc Audio back to the current URL
currentTime Sets or returns the current audio playback position (in seconds)
defaultMuted Sets or returns whether the default audio mute
defaultPlaybackRate Sets or returns the default audio playback speed
duration Returns the current audio length (in seconds)
ended Whether to return the audio playback has ended
error It returns an error status of the audio objects MediaError
loop Sets or returns whether the audio should be replayed at the end of
mediaGroup Sets or returns the combined audio belongs (for connecting multiple audio elements)
muted Sets or returns whether the audio is muted
networkState Returns the current network status audio
paused Sets or returns whether the audio pause
playbackRate Sets or returns the audio playback speed
played Returns the audio portion of the object has been played TimeRanges
preload Sets or returns whether the audio should be loaded when the page loads
readyState Returns current audio readiness
seekable Back TimeRanges object audio portion of the addressable representation
seeking Whether the user is returned to find audio
src Sets or returns the current source audio elements
textTracks Back TextTrackList track objects available text representation
volume Sets or returns the volume of audio

Audio Object

method description
addTextTrack () Adding a new text in the audio track
canPlayType () Check if your browser can play the specified audio type
fastSeek () Specifies the playing time in the audio player.
getStartDate () It returns a new Date object that represents the current timeline offset
load () Reload the audio elements
play () Start playing the audio
pause () Pause the currently playing audio

Standard properties and events

Canvas object also supports the standard attributes and events .


related articles

HTML Tutorial: the HTML5 Audio

HTML Reference Manual: HTML <Audio> tag

HTML Audio / Video DOM Reference Manual: HTML Audio / Video