HTML Audio/Video


The <audio> and <video> elements have methods, properties, and events in the HTML5 DOM.

Audio/Video Methods in HTML

Method Description
addTextTrack() This function adds a new text track to the audio/video.
canPlayType() Checks whether the browser is capable of playing the specified audio/video format.
load() The audio/video element is reloaded.
play() Starts the audio/video playback.
pause() The currently playing audio/video is paused.

Audio/Video Properties in HTML

Property Description
audioTracks Returns an Audio Track List object containing a list of available audio tracks.
autoplay Sets or returns whether the audio/video should begin playing immediately after it is loaded.
buffered Returns a Time Ranges object containing the buffered audio/video segments.
controller Returns the Media Controller object, which represents the current audio/video media controller.
controls Sets or returns whether audio/video controls (such as play/pause) should be displayed.
crossOrigin Sets or returns the audio/CORS video's settings.
currentSrc The current audio/URL video's is returned.
currentTime Sets or returns the current audio/video playback position (in seconds).
defaultMuted Determines whether the audio/video should be muted by default.
defaultPlaybackRate Sets or returns the audio/video playback's default speed.
duration The current audio/length video's is returned (in seconds).
ended Returns whether or not the audio/video playback has finished.
error Returns a Media Error object representing the audio/video error state.
loop Sets or returns whether the audio/video should be restarted after it has finished.
mediaGroup Sets or returns the group to which the audio/video element belongs (used to connect multiple audio/video elements).
muted Sets or returns whether or not the audio/video is muted.
networkState Returns the audio/video network's current state.
paused Returns whether or not the audio/video is paused.
playbackRate Sets or returns the audio/video playback speed.
played Returns a Time Ranges object containing the audio/video segments that were played.
preload If the audio/video should be loaded when the page loads, this property specifies or returns whether it should be loaded.
readyState Returns the audio/current video's ready state.
seekable Returns a Time Ranges object containing the seek able audio/video segments.
seeking Returns whether the user is currently looking for something in the audio/video.
src Sets or returns the audio/video element's current source.
startDate The current time offset is represented by a Date object.
textTracks Returns a Text Track List object containing a list of available text tracks.
videoTracks Returns a Video Track List object containing a list of available video tracks.
volume Sets or returns the audio/video volume.

Audio/Video Events in HTML

Event Description
abort When the loading of an audio/video file is interrupted, this event is triggered.
canplay When the browser is ready to play the audio/video, this event is triggered.
canplaythrough When the browser can play the audio/video without pausing for buffering, this event is triggered.
durationchange When the duration of the audio/video is changed, this event is triggered.
emptied When the current playlist is empty, this method is called.
ended When the current playlist is finished, this method is called.
error When an error occurs during the loading of an audio/video, this event is triggered.
loadeddata When the browser has loaded the current frame of the audio/video, this event occurs.
loadedmetadata When the browser has loaded meta data for the audio/video, this event occurs.
loadstart When the browser begins looking for the audio/video, this event occurs.
pause When the audio/video is paused, this event is triggered.
play When the audio/video has started or is no longer paused, this event occurs.
playing When the audio/video is playing after being paused or stopped for buffering, this event occurs.
progress When the browser is downloading the audio/video, this event occurs.
ratechange When the audio/video playback speed is changed, this event occurs.
seeked When the user has finished moving/skipping to a new position in the audio/video, this event is triggered.
seeking When the user begins moving/skipping to a new position in the audio/video, this event occurs.
stalled When the browser tries to get media data but none is available, this event is triggered.
suspend When the browser intentionally does not receive media data, this event is triggered.
timeupdate When the current playback position changes, this function is called.
volumechange When the volume is changed, this function is triggered.
waiting When the video stops because it needs to buffer the next frame, this event is triggered.