HTMLMediaElement

HTMLMediaElement interface adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video. HTMLVideoElement and HTMLAudioElement elements both inherit this interface.

特性

This interface also inherits properties from its ancestors HTMLElement , Element , Node ,和 EventTarget .

HTMLMediaElement.audioTracks
A AudioTrackList that lists the AudioTrack objects contained in the element.
HTMLMediaElement.autoplay

A Boolean that reflects the autoplay HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption.

注意 : Automatically playing audio when the user doesn't expect or desire it is a poor user experience and should be avoided in most cases, though there are exceptions. See the Autoplay guide for media and Web Audio APIs for more information. Keep in mind that browsers may ignore autoplay requests, so you should ensure that your code isn't dependent on autoplay working.
HTMLMediaElement.buffered 只读
返回 TimeRanges object that indicates the ranges of the media source that the browser has buffered (if any) at the moment the buffered property is accessed.
HTMLMediaElement.controller
MediaController object that represents the media controller assigned to the element, or null if none is assigned.
HTMLMediaElement.controls
Boolean that reflects the controls HTML attribute, indicating whether user interface items for controlling the resource should be displayed.
HTMLMediaElement.controlsList 只读
返回 DOMTokenList that helps the user agent select what controls to show on the media element whenever the user agent shows its own set of controls. The DOMTokenList takes one or more of three possible values: nodownload , nofullscreen ,和 noremoteplayback .
HTMLMediaElement.crossOrigin
A DOMString indicating the CORS setting for this media element.
HTMLMediaElement.currentSrc 只读
返回 DOMString with the absolute URL of the chosen media resource.
HTMLMediaElement.currentTime
A double-precision floating-point value indicating the current playback time in seconds; if the media has not started to play and has not been seeked, this value is the media's initial playback time. Setting this value seeks the media to the new time. The time is specified relative to the media's timeline.
HTMLMediaElement.defaultMuted
A Boolean that reflects the muted HTML attribute, which indicates whether the media element's audio output should be muted by default.
HTMLMediaElement.defaultPlaybackRate
A double indicating the default playback rate for the media.
HTMLMediaElement.disableRemotePlayback
A Boolean that sets or returns the remote playback state, indicating whether the media element is allowed to have a remote playback UI.
HTMLMediaElement.duration 只读
A read-only double-precision floating-point value indicating the total duration of the media in seconds. If no media data is available, the returned value is NaN . If the media is of indefinite length (such as streamed live media, a WebRTC call's media, or similar), the value is +Infinity .
HTMLMediaElement.ended 只读
返回 Boolean that indicates whether the media element has finished playing.
HTMLMediaElement.error 只读
返回 MediaError object for the most recent error, or null if there has not been an error.
HTMLMediaElement.loop
A Boolean that reflects the loop HTML attribute, which indicates whether the media element should start over when it reaches the end.
HTMLMediaElement.mediaGroup
A DOMString that reflects the mediagroup HTML attribute, which indicates the name of the group of elements it belongs to. A group of media elements shares a common MediaController .
HTMLMediaElement.mediaKeys 只读
返回 MediaKeys object or null . MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback.
HTMLMediaElement.mozAudioCaptured 只读
返回 Boolean . Related to audio stream capture.
HTMLMediaElement.mozFragmentEnd
double that provides access to the fragment end time if the media element has a fragment URI for currentSrc , otherwise it is equal to the media duration.
HTMLMediaElement.mozFrameBufferLength

unsigned long that indicates the number of samples that will be returned in the framebuffer of each MozAudioAvailable event. This number is a total for all channels, and by default is set to be the number of channels * 1024 (e.g., 2 channels * 1024 samples = 2048 total).

mozFrameBufferLength property can be set to a new value for lower latency, larger amounts of data, etc. The size given must be a number between 512 and 16384. Using any other size results in an exception being thrown. The best time to set a new length is after the loadedmetadata event fires, when the audio info is known, but before the audio has started or MozAudioAvailable events have begun firing.

HTMLMediaElement.mozSampleRate 只读
返回 double representing the number of samples per second that will be played. For example, 44100 samples per second is the sample rate used by CD audio.
HTMLMediaElement.muted
Boolean that determines whether audio is muted. true if the audio is muted and false 否则。
HTMLMediaElement.networkState 只读
返回 unsigned short (enumeration) indicating the current state of fetching the media over the network.
HTMLMediaElement.paused 只读
返回 Boolean that indicates whether the media element is paused.
HTMLMediaElement.playbackRate
double that indicates the rate at which the media is being played back.
HTMLMediaElement.played 只读
返回 TimeRanges object that contains the ranges of the media source that the browser has played, if any.
HTMLMediaElement.preload
DOMString that reflects the preload HTML attribute, indicating what data should be preloaded, if any. Possible values are: none , metadata , auto .
HTMLMediaElement.preservesPitch
Boolean that determines if the pitch of the sound will be preserved. If set to false , the pitch will adjust to the speed of the audio. This is implemented with prefixes in Firefox ( mozPreservesPitch ) and WebKit ( webkitPreservesPitch ).
HTMLMediaElement.readyState 只读
返回 unsigned short (enumeration) indicating the readiness state of the media.
HTMLMediaElement.seekable 只读
返回 TimeRanges object that contains the time ranges that the user is able to seek to, if any.
HTMLMediaElement.seeking 只读
返回 Boolean that indicates whether the media is in the process of seeking to a new position.
HTMLMediaElement.sinkId 只读
返回 DOMString that is the unique ID of the audio device delivering output, or an empty string if it is using the user agent default. This ID should be one of the MediaDeviceInfo.deviceid values returned from MediaDevices.enumerateDevices() , id-multimedia ,或 id-communications .
HTMLMediaElement.src
DOMString that reflects the src HTML attribute, which contains the URL of a media resource to use.
HTMLMediaElement.srcObject
MediaStream representing the media to play or that has played in the current HTMLMediaElement ,或 null if not assigned.
HTMLMediaElement.textTracks 只读
Returns the list of TextTrack objects contained in the element.
HTMLMediaElement.videoTracks 只读
Returns the list of VideoTrack objects contained in the element.
HTMLMediaElement.volume
double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest).

事件处理程序

HTMLMediaElement.onencrypted
设置 EventHandler called when the media is encrypted.
HTMLMediaElement.onwaitingforkey
设置 EventHandler called when playback is blocked while waiting for an encryption key.

Obsolete attributes

These attributes are obsolete and should not be used, even if a browser still supports them.

HTMLMediaElement.initialTime 只读
返回 double that indicates the initial playback position in seconds.
HTMLMediaElement.mozChannels 只读
返回 double representing the number of channels in the audio resource (e.g., 2 for stereo).

Obsolete event handlers

HTMLMediaElement.onmozinterruptbegin
设置 EventHandler called when the media element is interrupted because of the Audio Channel manager. This was Firefox-specific, having been implemented for Firefox OS, and was removed in Firefox 55.
HTMLMediaElement.onmozinterruptend
设置 EventHandler called when the interruption is concluded. This was Firefox-specific, having been implemented for Firefox OS, and was removed in Firefox 55.

方法

This interface also inherits methods from its ancestors HTMLElement , Element , Node ,和 EventTarget .

HTMLMediaElement.addTextTrack()
Adds a text track (such as a track for subtitles) to a media element.
HTMLMediaElement.captureStream()
返回 MediaStream , captures a stream of the media content.
HTMLMediaElement.canPlayType()
Given a string specifying a MIME media type (potentially with the codecs parameter included), canPlayType() returns the string probably if the media should be playable, maybe if there's not enough information to determine whether the media will play or not, or an empty string if the media cannot be played.
HTMLMediaElement.fastSeek()
Directly seeks to the given time.
HTMLMediaElement.load()
Resets the media to the beginning and selects the best available source from the sources provided using the src attribute or the <source> 元素。
HTMLMediaElement.mozCaptureStream()
[enter description]
HTMLMediaElement.mozCaptureStreamUntilEnded()
[enter description]
HTMLMediaElement.mozGetMetadata()
返回 Object , which contains properties that represent metadata from the playing media resource as {key: value} pairs. A separate copy of the data is returned each time the method is called. This method must be called after the loadedmetadata 事件被激发。
HTMLMediaElement.pause()
Pauses the media playback.
HTMLMediaElement.play()
Begins playback of the media.
HTMLMediaElement.seekToNextFrame()
Seeks to the next frame in the media. This non-standard, experimental method makes it possible to manually drive reading and rendering of media at a custom speed, or to move through the media frame-by-frame to perform filtering or other operations.
HTMLMediaElement.setMediaKeys()
返回 Promise . Sets the MediaKeys keys to use when decrypting media during playback.
HTMLMediaElement.setSinkId()
Sets the ID of the audio device to use for output and returns a Promise . This only works when the application is authorized to use the specified device.

Obsolete methods

These methods are obsolete and should not be used, even if a browser still supports them.

HTMLMediaElement.mozLoadFrom()
This method, available only in Mozilla's implementation, loads data from another media element. This works similarly to load() except that instead of running the normal resource selection algorithm, the source is simply set to the other element's currentSrc . This is optimized so this element gets access to all of the other element's cached and buffered data; in fact, the two elements share downloaded data, so data downloaded by either element is available to both.

Events

Inherits methods from its parent, HTMLElement , defined in the GlobalEventHandlers mixin. Listen to these events using addEventListener() 或通过把事件监听器赋值给 on eventname 特性为此接口。

abort
Fired when the resource was not fully loaded, but not as the result of an error.
canplay
Fired when the user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content
canplaythrough
Fired when the user agent can play the media, and estimates that enough data has been loaded to play the media up to its end without having to stop for further buffering of content.
durationchange
Fired when the duration attribute has been updated.
emptied
Fired when the media has become empty; for example, when the media has already been loaded (or partially loaded), and the HTMLMediaElement.load() method is called to reload it.
ended
Fired when playback stops when end of the media (<audio> or <video>) is reached or because no further data is available.
error
Fired when the resource could not be loaded due to an error.
loadeddata
Fired when the first frame of the media has finished loading.
loadedmetadata
Fired when the metadata has been loaded
loadstart
Fired when the browser has started to load a resource.
pause
Fired when a request to pause play is handled and the activity has entered its paused state, most commonly occurring when the media's HTMLMediaElement.pause() method is called.
play
Fired when the paused property is changed from true to false , as a result of the HTMLMediaElement.play() method, or the autoplay attribute
playing
Fired when playback is ready to start after having been paused or delayed due to lack of data
progress
Fired periodically as the browser loads a resource.
ratechange
Fired when the playback rate has changed.
seeked
Fired when a seek operation completes
seeking
Fired when a seek operation begins
stalled
Fired when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
suspend
Fired when the media data loading has been suspended.
timeupdate
Fired when the time indicated by the currentTime attribute has been updated
volumechange
Fired when the volume has changed.
waiting
Fired when playback has stopped because of a temporary lack of data

规范

规范 状态 Comment
加密媒体扩展
The definition of 'Encrypted Media Extensions' in that specification.
Recommendation 添加 MediaKeys , MediaEncryptedEvent , setMediaKeys , onencrypted ,和 onwaitingforkey .
HTML Living Standard
The definition of 'HTMLMediaElement' in that specification.
实时标准 No change from HTML5
HTML5
The definition of 'HTMLMediaElement' in that specification.
Recommendation 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLMediaElement Chrome 1 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 11 Safari iOS 2 Samsung Internet Android 1.0
abort event Chrome Yes Edge ≤79 Firefox Yes IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
addTextTrack Chrome 42
42
26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android 42
42
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 42
42
32
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
4.0
3.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
audioTracks Chrome No Edge 12 — 79 Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE ? Opera Yes Safari Yes WebView Android No Chrome Android No Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android Yes Safari iOS Yes Samsung Internet Android No
autoplay Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera 30 Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android 30 Safari iOS Yes Samsung Internet Android 4.0
buffered Chrome 43 Edge 12 Firefox 4 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
canplay event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
canplaythrough event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
canPlayType() Chrome Yes Edge 12 Firefox 3.5
3.5
Prior to Firefox 28, canPlayType() returned probably when asked about WebM audio or video files without the codecs parameter. Since multiple codecs are supported, this is not enough information to determine if a file can be played, so maybe is now correctly returned.
IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
captureStream Chrome 62 Edge 79 Firefox 15
Prefixed
15
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera 49 Safari No WebView Android 62 Chrome Android 62 Firefox Android 15
Prefixed
15
Prefixed
Prefixed Implemented with the vendor prefix: moz
Opera Android 46 Safari iOS No Samsung Internet Android 8.0
controller Chrome No Edge No Firefox No
不支持 No
Firefox doesn't implement this yet. See bug 847377 .
IE ? Opera No Safari ? WebView Android No Chrome Android No Firefox Android No
不支持 No
Firefox doesn't implement this yet. See bug 847377 .
Opera Android No Safari iOS ? Samsung Internet Android No
controls Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
controlsList Chrome 58 Edge ≤79 Firefox ? IE ? Opera 45 Safari ? WebView Android 58 Chrome Android 58 Firefox Android ? Opera Android 43 Safari iOS ? Samsung Internet Android 7.0
crossOrigin Chrome 43 Edge 13 Firefox 22
22
不支持 12 — 22
Alternate Name
Alternate Name Uses the non-standard name: crossorigin
IE 9 Opera Yes Safari 10 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
currentSrc Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
currentTime Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
defaultMuted Chrome 43 Edge 12 Firefox 11 IE ? Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android 14 Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
defaultPlaybackRate Chrome 43 Edge 12 Firefox 20 IE 9 Opera Yes Safari Yes WebView Android 43 Chrome Android 43 Firefox Android 20 Opera Android ? Safari iOS ? Samsung Internet Android 4.0
disableRemotePlayback Chrome 49 Edge 12 Firefox 20 IE 9 Opera Yes Safari Yes WebView Android 49 Chrome Android 49 Firefox Android 15 Opera Android Yes Safari iOS Yes Samsung Internet Android 5.0
duration Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
durationchange event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
emptied event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
ended Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
ended event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
error Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
error event Chrome Yes Edge ≤79 Firefox Yes IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
fastSeek Chrome No Edge No Firefox 31 IE ? Opera ? Safari Yes WebView Android ? Chrome Android ? Firefox Android 31 Opera Android ? Safari iOS ? Samsung Internet Android ?
initialTime
弃用 非标
Chrome ? Edge ? Firefox 9 — 23 IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android 9 — 23 Opera Android ? Safari iOS ? Samsung Internet Android ?
load Chrome 1 Edge 12 Firefox 3.6 IE ? Opera Yes Safari 6 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
loadeddata event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
loadedmetadata event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
loadstart event Chrome Yes Edge ≤79 Firefox Yes IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
loop Chrome 43 Edge 12 Firefox 11 IE 9 Opera Yes Safari Yes WebView Android 43 Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
mediaGroup Chrome No Edge No Firefox No
不支持 No
Firefox doesn't implement this yet. See bug 847377 .
IE ? Opera ? Safari ? WebView Android No Chrome Android No Firefox Android No
不支持 No
Firefox doesn't implement this yet. See bug 847377 .
Opera Android ? Safari iOS ? Samsung Internet Android No
mediaKeys Chrome Yes Edge 13 Firefox Yes IE ? Opera Yes Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
mozAudioCaptured
弃用 非标
Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
mozCaptureStreamUntilEnded
弃用 非标
Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
mozChannels
弃用 非标
Chrome No Edge No Firefox 4 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 4 Opera Android No Safari iOS No Samsung Internet Android No
mozFragmentEnd
弃用 非标
Chrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
mozFrameBufferLength
弃用 非标
Chrome No Edge No Firefox 4 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 4 Opera Android No Safari iOS No Samsung Internet Android No
mozGetMetadata Chrome No Edge No Firefox 17 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 17 Opera Android No Safari iOS No Samsung Internet Android No
mozLoadFrom
弃用 非标
Chrome No Edge No Firefox 3.6 — 24 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 4 — 24 Opera Android No Safari iOS No Samsung Internet Android No
mozSampleRate
弃用 非标
Chrome No Edge No Firefox 4 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 4 Opera Android No Safari iOS No Samsung Internet Android No
muted Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
networkState Chrome 43 Edge 12 Firefox 3.5
3.5
NETWORK_LOADED state was removed to align with the HTML spec in Firefox 4.
IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
onencrypted Chrome Yes Edge 13 Firefox Yes IE ? Opera Yes Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
onerror Chrome Yes Edge 12 Firefox 3.5 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
onmozinterruptbegin
弃用 非标
Chrome ? Edge ? Firefox ? — 55 IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? — 55 Opera Android ? Safari iOS ? Samsung Internet Android ?
onmozinterruptend Chrome ? Edge ? Firefox ? — 55 IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? — 55 Opera Android ? Safari iOS ? Samsung Internet Android ?
onwaitingforkey Chrome 55 Edge 79 Firefox Yes IE ? Opera 42 Safari ? WebView Android 55 Chrome Android 55 Firefox Android ? Opera Android 42 Safari iOS ? Samsung Internet Android 6.0
pause Chrome Yes Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
pause event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
paused Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
play Chrome 1 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 6 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 11 Safari iOS 6 Samsung Internet Android 1.0
play event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
playbackRate Chrome 43 Edge 12 Firefox 20 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 20 Opera Android ? Safari iOS ? Samsung Internet Android Yes
played Chrome 43 Edge 12 Firefox 15 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 15 Opera Android ? Safari iOS ? Samsung Internet Android Yes
playing event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
preload Chrome 43 Edge 12 Firefox 4 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android ? Safari iOS ? Samsung Internet Android Yes
preservesPitch
弃用
Chrome Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 79
Prefixed
79
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 20
Prefixed
20
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera No Safari 4
Prefixed
4
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android No Safari iOS 4
Prefixed
4
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android Yes
progress event Chrome Yes Edge ≤79 Firefox Yes IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android ? Safari iOS ? Samsung Internet Android Yes
ratechange event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
readyState Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android 43 Chrome Android 43 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 4.0
seekable Chrome 43 Edge 12 Firefox 8 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 8 Opera Android ? Safari iOS ? Samsung Internet Android Yes
seeked event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
seeking Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
seeking event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
seekToNextFrame
弃用
Chrome No Edge No Firefox 49
Disabled
49
Disabled
Disabled From version 49: this feature is behind the media.seekToNextFrame preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE ? Opera ? Safari ? WebView Android No Chrome Android ? Firefox Android 49
Disabled
49
Disabled
Disabled From version 49: this feature is behind the media.seekToNextFrame preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android ? Safari iOS ? Samsung Internet Android ?
setMediaKeys Chrome Yes Edge 13 Firefox Yes IE ? Opera Yes Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
setSinkId Chrome 49 Edge 17 Firefox 64
Disabled
64
Disabled
Disabled From version 64: this feature is behind the media.setsinkid.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE No Opera 36 Safari ? WebView Android No
不支持 No
Not availabe due to a limitation in Android .
Chrome Android No
不支持 No
Not availabe due to a limitation in Android .
Firefox Android 64
Disabled
64
Disabled
Disabled From version 64: this feature is behind the media.setsinkid.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 36 Safari iOS ? Samsung Internet Android No
不支持 No
Not availabe due to a limitation in Android .
sinkId
Chrome 49 Edge 17 Firefox ? IE ? Opera Yes Safari ? WebView Android 49 Chrome Android 49 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
src Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
srcObject Chrome 部分支持 52
部分支持 52
Currently only supports MediaStream 对象。
Edge 部分支持 12
部分支持 12
Currently only supports MediaStream 对象。
Firefox 部分支持 42
部分支持 42
Currently only supports MediaStream 对象。
不支持 18 — 58
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera 部分支持 39
部分支持 39
Currently only supports MediaStream 对象。
Safari 11 WebView Android 部分支持 52
部分支持 52
Currently only supports MediaStream 对象。
Chrome Android 部分支持 52
部分支持 52
Currently only supports MediaStream 对象。
Firefox Android 部分支持 42
部分支持 42
Currently only supports MediaStream 对象。
不支持 18 — 58
Prefixed
Prefixed Implemented with the vendor prefix: moz
Opera Android 部分支持 41
部分支持 41
Currently only supports MediaStream 对象。
Safari iOS 11 Samsung Internet Android 部分支持 6.0
部分支持 6.0
Currently only supports MediaStream 对象。
stalled event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
suspend event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
textTracks Chrome Yes Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android ? Chrome Android ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
timeupdate event Chrome 3 Edge 12 Firefox 3.5 IE 9 Opera 10.5 Safari 3.1 WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
videoTracks Chrome No Edge 12 — 79 Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE ? Opera ? Safari Yes WebView Android ? Chrome Android ? Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android ? Safari iOS ? Samsung Internet Android ?
volume Chrome 43 Edge 12 Firefox 3.5 IE 9 Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
volumechange event Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
waiting event Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持
完整支持
部分支持
部分支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
用户必须明确启用此特征。
使用非标名称。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅

References

指南

  1. HTMLMediaElement
  2. 特性
    1. audioTracks
    2. autoplay
    3. buffered
    4. controller
    5. controls
    6. controlsList
    7. crossOrigin
    8. currentSrc
    9. currentTime
    10. defaultMuted
    11. defaultPlaybackRate
    12. duration
    13. ended
    14. error
    15. initialTime
    16. loop
    17. mediaGroup
    18. muted
    19. networkState
    20. onerror
    21. paused
    22. playbackRate
    23. readyState
    24. seekable
    25. sinkId
    26. src
    27. srcObject
    28. textTracks
    29. videoTracks
    30. volume
  3. 方法
    1. canPlayType()
    2. captureStream()
    3. fastSeek()
    4. load()
    5. msInsertAudioEffect()
    6. pause()
    7. play()
    8. seekToNextFrame()
    9. setMediaKeys()
    10. setSinkId()
  4. Events
    1. abort
    2. canplay
    3. canplaythrough
    4. durationchange
    5. emptied
    6. ended
    7. error
    8. loadeddata
    9. loadedmetadata
    10. loadstart
    11. pause
    12. play
    13. progress
    14. ratechange
    15. seeked
    16. seeking
    17. stalled
    18. suspend
    19. timeupdate
    20. volumechange
    21. waiting
  5. 继承:
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  6. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLElement
    22. HTMLEmbedElement
    23. HTMLFieldSetElement
    24. HTMLFormControlsCollection
    25. HTMLFormElement
    26. HTMLFrameSetElement
    27. HTMLHRElement
    28. HTMLHeadElement
    29. HTMLHeadingElement
    30. HTMLHtmlElement
    31. HTMLIFrameElement
    32. HTMLImageElement
    33. HTMLInputElement
    34. HTMLIsIndexElement
    35. HTMLKeygenElement
    36. HTMLLIElement
    37. HTMLLabelElement
    38. HTMLLegendElement
    39. HTMLLinkElement
    40. HTMLMapElement
    41. HTMLMetaElement
    42. HTMLMeterElement
    43. HTMLModElement
    44. HTMLOListElement
    45. HTMLObjectElement
    46. HTMLOptGroupElement
    47. HTMLOptionElement
    48. HTMLOptionsCollection
    49. HTMLOutputElement
    50. HTMLParagraphElement
    51. HTMLParamElement
    52. HTMLPictureElement
    53. HTMLPreElement
    54. HTMLProgressElement
    55. HTMLQuoteElement
    56. HTMLScriptElement
    57. HTMLSelectElement
    58. HTMLShadowElement
    59. HTMLSourceElement
    60. HTMLSpanElement
    61. HTMLStyleElement
    62. HTMLTableCaptionElement
    63. HTMLTableCellElement
    64. HTMLTableColElement
    65. HTMLTableDataCellElement
    66. HTMLTableElement
    67. HTMLTableHeaderCellElement
    68. HTMLTableRowElement
    69. HTMLTableSectionElement
    70. HTMLTemplateElement
    71. HTMLTextAreaElement
    72. HTMLTimeElement
    73. HTMLTitleElement
    74. HTMLTrackElement
    75. HTMLUListElement
    76. HTMLUnknownElement
    77. HTMLVideoElement
    78. HashChangeEvent
    79. History
    80. ImageData
    81. Location
    82. MessageChannel
    83. MessageEvent
    84. MessagePort
    85. Navigator
    86. NavigatorGeolocation
    87. NavigatorID
    88. NavigatorLanguage
    89. NavigatorOnLine
    90. NavigatorPlugins
    91. PageTransitionEvent
    92. Plugin
    93. PluginArray
    94. PopStateEvent
    95. PortCollection
    96. PromiseRejectionEvent
    97. RadioNodeList
    98. Transferable
    99. ValidityState
    100. Window
    101. WindowBase64
    102. WindowEventHandlers
    103. WindowTimers