HTMLMediaElement

Cette traduction est incomplète. Aidez à traduire cet article depuis l'anglais.

L' interface HTMLMediaElement ajoute à HTMLElement les propriétés et les méthodes nécessaires au support d'actions basics sur des médias qui sont communes aux vidéos et aux document audios. HTMLVideoElement et HTMLAudioElement héritent de cette interface.

Properties

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

HTMLMediaElement.audioTracks
Is a AudioTrackList that lists the AudioTrack objects contained in the element.
HTMLMediaElement.autoplay
Is 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.
HTMLMediaElement.bufferedLecture seule
Returns a 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
Is a MediaController object that represents the media controller assigned to the element, or null if none is assigned.
HTMLMediaElement.controls
Is a Boolean that reflects the controls HTML attribute, indicating whether user interface items for controlling the resource should be displayed.
HTMLMediaElement.crossOrigin
Is a DOMString indicating the CORS setting for this media element.
HTMLMediaElement.currentSrcLecture seule
Returns a DOMString with the absolute URL of the chosen media resource.
HTMLMediaElement.currentTime
Is a double indicating the current playback time in seconds. Setting this value seeks the media to the new time.
HTMLMediaElement.defaultMuted
Is a Boolean that reflects the muted HTML attribute, which indicates whether the media element's audio output should be muted by default.
HTMLMediaElement.defaultPlaybackRate
Is a double indicating the default playback rate for the media.
HTMLMediaElement.disableRemotePlayback
Is a Boolean that sets or returns the remote playback state, indicating whether the media element is allowed to have a remote playback UI.
HTMLMediaElement.durationLecture seule
Returns a double indicating the length of the media in seconds, or 0 if no media data is available.
HTMLMediaElement.endedLecture seule
Returns a Boolean that indicates whether the media element has finished playing.
HTMLMediaElement.errorLecture seule
Returns a MediaError object for the most recent error, or null if there has not been an error.
HTMLMediaElement.initialTimeLecture seule
Returns a double that indicates the initial playback position in seconds.
HTMLMediaElement.loop
Is a Boolean that reflects the loop HTML attribute, which indicates whether the media element should start over when it reaches the end.
HTMLMediaElement.mediaGroup
Is 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.mediaKeysLecture seule
Returns a MediaKeys object or null. MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback.
HTMLMediaElement.mozAudioCapturedLecture seule
Returns a Boolean. Related to audio stream capture.
HTMLMediaElement.mozAudioChannelType
(Firefox OS only) Is a String that can be used to set the audio channel that the sound coming from an <audio> or <video> element will play in, on a Firefox OS device. See Using the AudioChannels API for more details.
HTMLMediaElement.mozChannelsLecture seule  
Returns a double representing the number of channels in the audio resource (e.g., 2 for stereo).
HTMLMediaElement.mozFragmentEnd
Is a 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  

Is a 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).

The 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.mozSampleRateLecture seule  
Returns a 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
Is a Boolean that determines whether audio is muted. true if the audio is muted and false otherwise.
HTMLMediaElement.networkStateLecture seule
Returns a unsigned short (enumeration) indicating the current state of fetching the media over the network.
HTMLMediaElement.pausedLecture seule
Returns a Boolean that indicates whether the media element is paused.
HTMLMediaElement.playbackRate
Is a double that indicates the rate at which the media is being played back. 
HTMLMediaElement.playedLecture seule
Returns a TimeRanges object that contains the ranges of the media source that the browser has played, if any.
HTMLMediaElement.preload
Is a DOMString that reflects the preload HTML attribute, indicating what data should be preloaded, if any. Possible values are: none, metadata, auto.
HTMLMediaElement.preservesPitch
Is a 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.readyStateLecture seule
Returns a unsigned short (enumeration) indicating the readiness state of the media.
HTMLMediaElement.seekableLecture seule
Returns a TimeRanges object that contains the time ranges that the user is able to seek to, if any.
HTMLMediaElement.seekingLecture seule
Returns a Boolean that indicates whether the media is in the process of seeking to a new position.
HTMLMediaElement.sinkIdLecture seule
Returns a 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.enumeratedDevices(), id-multimedia, or id-communications.
HTMLMediaElement.src
Is a DOMString that reflects the src HTML attribute, which contains the URL of a media resource to use.
HTMLMediaElement.srcObject
Is a MediaStream representing the media to play or that has played in the current HTMLMediaElement.
HTMLMediaElement.textTracksLecture seule
Returns the list of TextTrack objects contained in the element.
HTMLMediaElement.videoTracksLecture seule
Returns the list of VideoTrack objects contained in the element.

Note: Gecko supports only single track playback, and the parsing of tracks' metadata is only available for media with the Ogg container format.

HTMLMediaElement.volume
Is a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest).

Event handler properties

HTMLMediaElement.onmozinterruptbegin
Sets the EventHandler called when the media element is interrupted because of the audiochannel manager.
HTMLMediaElement.onmozinterruptend
Sets the EventHandler called when the interruption is concluded.
HTMLMediaElement.onencrypted
Sets the EventHandler called when the media is encrypted.

Methods

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

HTMLMediaElement.addTextTrack()
Adds a text track (such as a track for subtitles) to a media element.
HTMLMediaElement.captureStream()
Returns MediaStream, captures a stream of the media content.
HTMLMediaElement.canPlayType()
Determines whether the specified media type can be played back.
HTMLMediaElement.fastSeek()
Directly seeks to the given time.
HTMLMediaElement.load()
Resets the media element and restarts the media resource. Any pending events are discarded. How much media data is fetched is still affected by the preload attribute. This method can be useful for releasing resources after any src attribute and source element descendants have been removed. Otherwise, it is usually unnecessary to use this method, unless required to rescan source element children after dynamic changes.
HTMLMediaElement.mozCaptureStream()
[enter description]
HTMLMediaElement.mozCaptureStreamUntilEnded()
[enter description]
HTMLMediaElement.mozGetMetadata()
Returns 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 event fires.
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.
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()
Returns 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.

Specifications

Specification Status Comment
WHATWG HTML Living Standard
La définition de 'HTMLMediaElement' dans cette spécification.
Standard évolutif No change from HTML5
HTML5
La définition de 'HTMLMediaElement' dans cette spécification.
Recommendation Initial definition.
Encrypted Media Extensions
La définition de 'Encrypted Media Extensions' dans cette spécification.
Version de travail Adds MediaKeys, MediaEncryptedEvent, and setMediaKeys.
Media Capture and Streams
La définition de 'HTMLMediaElement' dans cette spécification.
Brouillon de l'éditeur Adds sinkId and setSinkId(), and captureStream().

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Oui) 3.5 (1.9.1) [1] 9 ? ?
buffered property (Oui) 4.0 (2.0) 9 ? ?
defaultMuted property (Oui) 11.0 (11.0) ? ? ?
loop property (Oui) 11.0 (11.0) 9 ? ?
seekable property (Oui) 8.0 (8.0) 9 ? ?
defaultPlaybackRate property (Oui) 20.0 (20.0) 9 ? ?
playbackRate property (Oui) 20.0 (20.0) 9 ? ?
preservesPitch property (Oui)webkit 20.0 (20.0)moz Pas de support Pas de support Pas de support
preload property (Oui) 4.0 (2.0)[2] ? ? ?
played property (Oui) 15.0 (15.0) ? ? ?
crossOrigin property (Oui) 12.0 (12.0)[3]
22.0 (22.0)
 
? ? ?
mozAudioChannelType property Pas de support Pas de support Pas de support Pas de support Pas de support
mozChannels, mozFrameBufferLength, mozSampleRate properties Pas de support 4.0 (2.0) Pas de support Pas de support Pas de support
mozGetMetadata() Pas de support 17.0 (17.0) Pas de support Pas de support Pas de support
mozLoadFrom() Obsolète depuis Gecko 24 Pas de support 3.6 (1.9.2) Pas de support Pas de support Pas de support
mozSrcObject property Pas de support 18.0 (18.0) Pas de support Pas de support Pas de support
initialTime property ? 9.0 (9.0)[4] ? ? ?
fastSeek method ? 31.0 (31.0) ? ? ?
startDate property ? Pas de support[8] ? ? ?
mediaGroup and controller properties ? Pas de support[9] ? ? ?
audioTracks, and videoTracks properties ? 33.0 (33.0) [5] ? ? ?
textTracks property ? Nightly build [6] ? ? ?
sinkId property and setSinkId() method 49.0 ? ? ? ?
seekToNextFrame() method ? 49 (49) [10] ? ? ?
srcObject 52.0 ? ? 39 ?
captureStream() 53.0 ? ? ? ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support (Oui) (Oui) (Oui) (Oui) ? (Oui) (Oui) (Oui)
buffered property (Oui) (Oui) 4.0 (2.0) (Oui) ? ? ? (Oui)
defaultMuted property (Oui) (Oui) 11.0 (11.0) (Oui) ? ? ? (Oui)
loop property (Oui) (Oui) 11.0 (11.0) (Oui) ? ? ? (Oui)
seekable property (Oui) (Oui) 8.0 (8.0) (Oui) ? ? ? (Oui)
defaultPlaybackRate property (Oui) (Oui) 20.0 (20.0) (Oui) ? ? ? (Oui)
playbackRate property (Oui) (Oui) 20.0 (20.0) (Oui) ? ? ? (Oui)
preservesPitch property (Oui)webkit (Oui) 20.0 (20.0)moz (Oui) Pas de support Pas de support Pas de support (Oui)
preload property (Oui) (Oui) 4.0 (2.0) (Oui) ? ? ? (Oui)
played property (Oui) (Oui) 15.0 (15.0) (Oui) ? ? ? (Oui)
crossOrigin property (Oui) (Oui) 12.0 (12.0)[3]
22.0 (22.0)
 
(Oui) ? ? ? (Oui)
mozAudiochannelType Pas de support Pas de support Pas de support 1.0.1 Pas de support Pas de support Pas de support Pas de support
mozChannels, mozFrameBufferLength, mozSampleRate properties Pas de support Pas de support 4.0 (2.0) (Oui) Pas de support Pas de support Pas de support Pas de support
mozGetMetadata() Pas de support Pas de support 17.0 (17.0) (Oui) Pas de support Pas de support Pas de support Pas de support
mozLoadFrom() Pas de support Pas de support 1.0 (1.9.2)[7] (Oui) Pas de support Pas de support Pas de support Pas de support
mozSrcObject property Pas de support Pas de support 18.0 (18.0) (Oui) Pas de support Pas de support Pas de support Pas de support
initialTime property ? ? 9.0 (9.0)[4] (Oui) ? ? ? ?
fastSeek method ? ? 31.0 (31.0) (Oui) ? ? ? ?
startDate property ? ? Pas de support[8] (Oui) ? ? ? ?
mediaGroup and controller properties ? ? Pas de support[9] (Oui) ? ? ? ?
audioTracks, and videoTracks properties ? ? 33.0 (33.0)[5] (Oui) ? ? ? ?
textTracks property ? ? Nightly build[6] (Oui) ? ? ? ?
sinkId property and setSinkId() method ? 49.0 ? ? ? ? ? 49.0
seekToNextFrame() method ? ? 49.0 (49) [10] ? ? ? ? ?
srcObject Pas de support 52.0 ? ? ? 39 ? 52.0
captureStream() Pas de support 53.0 ? ? ? ? ? 53.0

[1] The NETWORK_LOADED state was removed to align with the HTML spec in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1).

[2] Previously Gecko implemented this as autobuffer.

[3] Gecko implements this in lowercase, i.e. crossorigin.

[4] The feature was removed in Gecko 23.0 (Firefox 23 / Thunderbird 23 / SeaMonkey 2.20).

[5] The implementation is hidden behind the media.track.enabled preference.

[6] The implementation is hidden behind the media.webvtt.enabled preference, defaulting there to true.

[7] This feature was removed in 24.0 (24).

[8] Gecko doesn't implement this yet. See bug 847376.

[9] Gecko doesn't implement this yet. See bug 847377.

[10] The preference media.seekToNextFrame must be enabled to use the seekToNextFrame() method.

See also

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : MrMargouillat
 Dernière mise à jour par : MrMargouillat,