Global Index
HTML5 JS API Index > Media Tutorials & Specs

HTMLMediaElement

Extends HTMLElement.

Extended by HTMLVideoElement, HTMLAudioElement
Properties
const unsigned short
HAVE_CURRENT_DATA = 2
Data for the immediate current playback position is available, but either not enough data is available that the user agent could successfully advance the current playback position in the direction of playback at all without immediately reverting to the HAVE_METADATA state, or there is no more data to obtain in the direction of playback.
const unsigned shortHAVE_ENOUGH_DATA = 4
const unsigned short
HAVE_FUTURE_DATA = 3
Data for the immediate current playback position is available, as well as enough data for the user agent to advance the current playback position in the direction of playback at least a little without immediately reverting to the HAVE_METADATA state, and the text tracks are ready.
const unsigned short
HAVE_METADATA = 1
Enough of the resource has been obtained that the duration of the resource is available. In the case of a video element, the dimensions of the video are also available. The API will no longer throw an exception when seeking. No media data is available for the immediate current playback position.
const unsigned short
HAVE_NOTHING = 0
No information regarding the media resource is available. No data for the current playback position is available. Media elements whose networkState attribute are set to NETWORK_EMPTY are always in the HAVE_NOTHING state.
const unsigned short
NETWORK_EMPTY = 0
The element has not yet been initialized. All attributes are in their initial states.
const unsigned short
NETWORK_IDLE = 1
The element's resource selection algorithm is active and has selected a resource, but it is not actually using the network at this time.
const unsigned short
NETWORK_LOADING = 2
The user agent is actively trying to download data.
const unsigned short
NETWORK_NO_SOURCE = 3
The element's resource selection algorithm is active, but it has not yet found a resource to use.
AudioTrackList
audioTracks
The audioTracks attribute of a media element must return a live AudioTrackList object representing the audio tracks available in the media element's media resource. The same object must be returned each time.
boolean
autoplay
The autoplay IDL attribute must reflect the content attribute of the same name.
TimeRanges
buffered
The buffered attribute must return a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has buffered, at the time the attribute is evaluated. Users agents must accurately determine the ranges available, even for media streams where this can only be determined by tedious inspection.
MediaController?
controller
The controller attribute on a media element, on getting, must return the element's current media controller, if any, or null otherwise.
boolean
controls
The controls IDL attribute must reflect the content attribute of the same name.
DOMString
crossOrigin
The crossOrigin IDL attribute must reflect the crossorigin content attribute, limited to only known values.
DOMString
currentSrc
The currentSrc IDL attribute is initially the empty string. Its value is changed by the resource selection algorithm defined below.
double
currentTime
The currentTime attribute must, on getting, return the media element's default playback start position, unless that is zero, in which case it must return the element's official playback position. The returned value must be expressed in seconds. On setting, if the media element has a current media controller, then the user agent must throw an InvalidStateError exception; otherwise, if the media element's readyState is HAVE_NOTHING, then it must set the media element's default playback start position to the new value; otherwise, it must set the official playback position to the new value and then seek to the new value.
boolean
defaultMuted
The defaultMuted IDL attribute must reflect the muted content attribute.
double
defaultPlaybackRate
The defaultPlaybackRate attribute gives the desired speed at which the media resource is to play, as a multiple of its intrinsic speed. The attribute is mutable: on getting it must return the last value it was set to, or 1.0 if it hasn't yet been set; on setting the attribute must be set to the new value.
unrestricted double
duration
The duration attribute must return the time of the end of the media resource, in seconds, on the media timeline. If no media data is available, then the attributes must return the Not-a-Number (NaN) value. If the media resource is not known to be bounded (e.g.
boolean
ended
The ended attribute must return true if, the last time the event loop reached step 1, the media element had ended playback and the direction of playback was forwards, and false otherwise.
MediaError?
error
All media elements have an associated error status, which records the last error the element encountered since its resource selection algorithm was last invoked. The error attribute, on getting, must return the MediaError object created for this last error, or null if there has not been an error.
boolean
loop
The loop IDL attribute must reflect the content attribute of the same name.
DOMString
mediaGroup
The mediaGroup IDL attribute on media elements must reflect the mediagroup content attribute.
boolean
muted
The muted IDL attribute must return the value to which it was last set. When a media element is created, if the element has a muted content attribute specified, then the muted IDL attribute should be set to true; otherwise, the user agents may set the value to the user's preferred value (e.g.
unsigned short
networkState
As media elements interact with the network, their current network activity is represented by the networkState attribute.
boolean
paused
The paused attribute represents whether the media element is paused or not. The attribute must initially be true.
double
playbackRate
The playbackRate attribute gives the effective playback rate (assuming there is no current media controller overriding it), which is the speed at which the media resource plays, as a multiple of its intrinsic speed. If it is not equal to the defaultPlaybackRate, then the implication is that the user is using a feature such as fast forward or slow motion playback.
TimeRanges
played
The played attribute must return a new static normalized TimeRanges object that represents the ranges of points on the media timeline of the media resource reached through the usual monotonic increase of the current playback position during normal playback, if any, at the time the attribute is evaluated.
DOMString
preload
The preload IDL attribute must reflect the content attribute of the same name, limited to only known values.
unsigned short
readyState
The readyState IDL attribute must, on getting, return the value described above that describes the current ready state of the media element.
TimeRanges
seekable
The seekable attribute must return a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to, at the time the attribute is evaluated.
boolean
seeking
The seeking attribute must initially have the value false.
DOMString
src
The src IDL attribute on media elements must reflect the content attribute of the same name.
TextTrackList
textTracks
The textTracks attribute of media elements must return a TextTrackList object representing the TextTrack objects of the text tracks in the media element's list of text tracks, in the same order as in the list of text tracks. The same object must be returned each time the attribute is accessed.
VideoTrackList
videoTracks
The videoTracks attribute of a media element must return a live VideoTrackList object representing the video tracks available in the media element's media resource. The same object must be returned each time.
double
volume
The volume IDL attribute must return the playback volume of any audio portions of the media element. On setting, if the new value is in the range 0.0 to 1.0 inclusive, the media element's playback volume must be set to the new value. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an IndexSizeError exception must be thrown instead.
Operations
TextTrackaddTextTrack(TextTrackKind kind, optional DOMString label, optional DOMString language)
CanPlayTypeResult
canPlayType(DOMString type)
The canPlayType(type) method must return the empty string if type is a type that the user agent knows it cannot render or is the type "application/octet-stream"; it must return "probably" if the user agent is confident that the type represents a media resource that it can render if used in with this audio or video element; and it must return "maybe" otherwise.
void
fastSeek(double time)
The fastSeek() method must seek to the time given by the method's argument, with the approximate-for-speed flag set.
Date
getStartDate()
The getStartDate() method must return a new Date object representing the current timeline offset.
void
load()
When the load() method on a media element is invoked, the user agent must run the media element load algorithm.
voidpause()
void
play()
When the play() method on a media element is invoked, the user agent must run the following steps.