HTML Audio/VideoDOM Reference


HTML Audio/VideoDOM Reference

HTML5 DOM provides methods, properties, and events for the <audio> and <video> elements.

These methods, properties, and events allow you to manipulate the <audio> and <video> elements using JavaScript.


HTML Audio/Video Methods

Method Description
addTextTrack() Adds a new text track to the audio/video.
canPlayType() Detects whether the browser can play the specified audio/video type.
load() Reloads the audio/video element.
play() Starts playing the audio/video.
pause() Pauses the currently playing audio/video.

HTML Audio/Video Properties

Property Description
audioTracks Returns the AudioTrackList object representing the available audio tracks.
autoplay Sets or returns whether the audio/video should play immediately after loading has finished.
buffered Returns the TimeRanges object representing the buffered parts of the audio/video.
controller Returns the MediaController object representing the current media controller of the audio/video.
controls Sets or returns whether the audio/video displays controls (such as play/pause, etc.).
crossOrigin Sets or returns the CORS setting of the audio/video.
currentSrc Returns the URL of the current audio/video.
currentTime Sets or returns the current playback position of the audio/video (in seconds).
defaultMuted Sets or returns whether the audio/video is muted by default.
defaultPlaybackRate Sets or returns the default playback speed of the audio/video.
duration Returns the length of the current audio/video (in seconds).
ended Returns whether the playback of the audio/video has ended.
error Returns the MediaError object representing the error state of the audio/video.
loop Sets or returns whether the audio/video should replay after it ends.
mediaGroup Sets or returns the group to which the audio/video belongs (used for connecting multiple audio/video elements).
muted Sets or returns whether the audio/video is muted.
networkState Returns the current network state of the audio/video.
paused Sets or returns whether the audio/video is paused.
playbackRate Sets or returns the playback speed of the audio/video.
played Returns the TimeRanges object representing the played parts of the audio/video.
preload Sets or returns whether the audio/video should be loaded after the page loads.
readyState Returns the current ready state of the audio/video.
seekable Returns the TimeRanges object representing the seekable parts of the audio/video.
seeking Returns whether the user is currently seeking in the audio/video.
src Sets or returns the current source of the audio/video element.
startDate Returns the Date object representing the current time offset.
textTracks Returns the TextTrackList object representing the available text tracks.
videoTracks Returns the VideoTrackList object representing the available video tracks.
volume Sets or returns the volume of the audio/video.

HTML Audio/Video Events

Event Description
abort Triggered when the loading of the audio/video is aborted.
canplay Triggered when the browser can start playing the audio/video.
canplaythrough Triggered when the browser can play without stopping due to buffering.
durationchange Triggered when the duration of the audio/video has changed.
emptied Triggered when the current playlist is empty.
ended Triggered when the current playlist has ended.
error Triggered when an error occurs during the loading of the audio/video.
loadeddata Triggered when the browser has loaded the current frame of the audio/video.
loadedmetadata Triggered when the browser has loaded the metadata of the audio/video.
loadstart Triggered when the browser starts seeking the audio/video.
pause Triggered when the audio/video has been paused.
play Triggered when the audio/video has started or is no longer paused.
playing Triggered when the audio/video is ready after being paused or stopped due to buffering.
progress Triggered when the browser is downloading the audio/video.
ratechange Triggered when the playback speed of the audio/video has changed.
seeked Triggered when the user has moved/jumped to a new position in the audio/video.
seeking Triggered when the user starts moving/jumping to a new position in the audio/video.
stalled Triggered when the browser tries to fetch media data, but the data is unavailable.
suspend Triggered when the browser deliberately does not fetch media data.
timeupdate Triggered when the current playback position has changed.
volumechange Triggered when the volume has changed.
waiting Triggered when the video stops because it needs to buffer the next frame.
Other Extensions