English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML audio/video

After we insert these audio and video tags into the page, we find that there are no audio files on the page, and the video files cannot be played. What is the reason for this? This is because we are missing some media elements. Below is a list of some media elements

HTML audio/video DOM reference manual

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

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

HTML audio/video method

methodDescription
addTextTrack()to the audio/video adds a new text track.
canPlayType()check if the browser can play the specified audio/video type.
load()reload the audio/video element.
play()start playing audio/video
pause()pause the currently playing audio/video

HTML audio/video properties

propertyDescription
audioTracksReturns an AudioTrackList object representing the available audio tracks.
autoplaySets or returns whether the audio should be played immediately after loading is complete./video
bufferedReturns the audio/The TimeRanges object representing the parts of the video that have been buffered.
controllerReturns the audio/The MediaController object representing the current media controller of the video.
controlsSets or returns the audio/Whether the video controls are displayed (such as play/(such as pause, etc.).
crossOriginSets or returns the audio/The CORS settings of the video.
currentSrcReturns the current audio/The URL of the video.
currentTimeSets or returns the audio/The current playback position in the video (in seconds).
defaultMutedSets or returns the audio/Whether the video is muted by default.
defaultPlaybackRateSets or returns the audio/The default playback speed of the video.
durationReturns the current audio/The length of the video (in seconds).
endedReturns the audio/Whether the playback of the video has ended.
errorReturns the audio/The MediaError object representing the video error state.
loopSets or returns the audio/Whether the video should be replayed at the end.
mediaGroupSets or returns the audio/The group to which the video belongs (used to connect multiple audio/The video element).
mutedSets or returns the audio/Whether the video is muted.
networkStateReturns the audio/The current network state of the video.
pausedSets or returns the audio/Whether the video is paused.
playbackRateSets or returns the audio/The playback speed of the video.
playedReturns the audio/The TimeRanges object representing the parts of the video that have been played.
preloadSets or returns the audio/Whether the video should be loaded after the page is loaded.
readyStateReturns the audio/The current ready state of the video.
seekableReturns the audio/The TimeRanges object representing the addressable parts of the video.
seekingReturns whether the user is currently on audio/Search within the video.
srcSets or returns the audio/The current source of the video element.
startDateReturns the Date object representing the current time offset.
textTracksReturns the TextTrackList object representing the available text tracks.
videoTracksReturns the VideoTrackList object representing the available video tracks.
volumeSets or returns the audio/The volume of the video.

HTML audio/Video event

EventDescription
abortWhen the audio/Triggered when the loading of the video has been aborted.
canplayTriggered when the browser can start playing audio./video
canplaythroughTriggered when the browser can play without stopping due to buffering.
durationchangeWhen the audio/Triggered when the duration of the video has changed.
emptiedTriggered when the current playlist is empty.
endedTriggered when the current playlist has ended.
errorWhen in the audio/Triggered when an error occurs during the video loading.
loadeddataWhen the browser has loaded audio/Triggered when the current frame of the video is loaded.
loadedmetadataWhen the browser has loaded audio/Triggered when the metadata of the video is loaded.
loadstartTriggered when the browser starts to search for audio/video
pauseWhen the audio/Triggered when the video has paused.
playWhen the audio/Triggered when the video has started or is no longer paused.
playingWhen the audio/Triggered when the video is ready after pausing or stopping due to buffering.
progressTriggered when the browser is downloading audio/video
ratechangeWhen the audio/Triggered when the video playback speed has changed.
seekedTriggered when the user has moved/Jump to audio/Triggered when a new position in the video is reached.
seekingTriggered when the user starts to move/Jump to audio/Triggered when a new position in the video is reached.
stalledTriggered when the browser tries to fetch media data but the data is not available.
suspendTriggered when the browser deliberately does not fetch media data.
timeupdateTriggered when the current playback position has changed.
volumechangeTriggered when the volume has changed.
waitingTriggered when the video stops due to the need to buffer the next frame.