The best HTML Audio / Video Tutorial In 2024, In this tutorial you can learn HTML Audio / Video DOM Reference,HTML audio / video method,HTML Audio / Video Properties,HTML Audio / Video Event,
HTML5 DOM for the <audio> and <video> element provides methods, properties, and events.
These methods, properties, and events that allow you to use JavaScript to manipulate the <audio> and <video> elements.
方法 | 描述 |
---|---|
addTextTrack() | 向音频/视频添加新的文本轨道。 |
canPlayType() | 检测浏览器是否能播放指定的音频/视频类型。 |
load() | 重新加载音频/视频元素。 |
play() | 开始播放音频/视频。 |
pause() | 暂停当前播放的音频/视频。 |
属性 | 描述 |
---|---|
audioTracks | 返回表示可用音频轨道的 AudioTrackList 对象。 |
autoplay | 设置或返回是否在加载完成后随即播放音频/视频。 |
buffered | 返回表示音频/视频已缓冲部分的 TimeRanges 对象。 |
controller | 返回表示音频/视频当前媒体控制器的 MediaController 对象。 |
controls | 设置或返回音频/视频是否显示控件(比如播放/暂停等)。 |
crossOrigin | 设置或返回音频/视频的 CORS 设置。 |
currentSrc | 返回当前音频/视频的 URL。 |
currentTime | 设置或返回音频/视频中的当前播放位置(以秒计)。 |
defaultMuted | 设置或返回音频/视频默认是否静音。 |
defaultPlaybackRate | 设置或返回音频/视频的默认播放速度。 |
duration | 返回当前音频/视频的长度(以秒计)。 |
ended | 返回音频/视频的播放是否已结束。 |
error | 返回表示音频/视频错误状态的 MediaError 对象。 |
loop | 设置或返回音频/视频是否应在结束时重新播放。 |
mediaGroup | 设置或返回音频/视频所属的组合(用于连接多个音频/视频元素)。 |
muted | 设置或返回音频/视频是否静音。 |
networkState | 返回音频/视频的当前网络状态。 |
paused | 设置或返回音频/视频是否暂停。 |
playbackRate | 设置或返回音频/视频播放的速度。 |
played | 返回表示音频/视频已播放部分的 TimeRanges 对象。 |
preload | 设置或返回音频/视频是否应该在页面加载后进行加载。 |
readyState | 返回音频/视频当前的就绪状态。 |
seekable | 返回表示音频/视频可寻址部分的 TimeRanges 对象。 |
seeking | 返回用户是否正在音频/视频中进行查找。 |
src | 设置或返回音频/视频元素的当前来源。 |
startDate | 返回表示当前时间偏移的 Date 对象。 |
textTracks | 返回表示可用文本轨道的 TextTrackList 对象。 |
videoTracks | 返回表示可用视频轨道的 VideoTrackList 对象。 |
volume | 设置或返回音频/视频的音量。 |
event | description |
---|---|
abort | Fires when the audio / video load has been abandoned. |
canplay | Fires when the browser can start playing the audio / video. |
canplaythrough | Fires when the browser can be played without pause due to buffering. |
durationchange | Fires when the audio / video length of time has changed. |
emptied | Fires when the current playlist is empty. |
ended | Fires when the current play list has ended. |
error | It is triggered when an error occurs in the audio / video during loading. |
loadeddata | Fires when the browser has loaded an audio / video of the current frame. |
loadedmetadata | Fires when the browser has loaded an audio / video metadata. |
loadstart | Fires when the browser start looking for audio / video. |
pause | Fires when the audio / video is paused. |
play | Fires when the audio / video has started or is no longer suspended. |
playing | Fires when the audio / video due to buffering and pause or stop after ready. |
progress | Fires when the browser is downloading the audio / video. |
ratechange | Fires when the audio / video playback speed has changed. |
seeked | Fires when the user has to move / jump to the audio / video in a new location. |
seeking | Fires when the user begins to move / jump to the audio / video to a new position. |
stalled | When the browser tries to obtain media data, but the data is not available when triggered. |
suspend | When the browser is triggered deliberately not get media data. |
timeupdate | Fires when the current playback position has changed. |
volumechange | Fires when the volume has been changed. |
waiting | Due to the need to trigger when the video frame buffer to the next stop. |