media element | media object
Presents audio or video data to the user. The media element provides the audio and video objects which are used to play sound and video content.
![]() ![]() |
DOM Information
Inheritance Hierarchy
Members
The media object has these types of members:
Events
The media object has these events.
| Event | Description |
|---|---|
| abort |
Fires when the user aborts the download. |
| blur |
Fires when the object loses the input focus. |
| change |
Fires when the contents of the object or selection have changed. |
| drag |
Fires on the source object continuously during a drag operation. |
| dragend |
Fires on the source object when the user releases the mouse at the close of a drag operation. |
| dragenter |
Fires on the target element when the user drags the object to a valid drop target. |
| dragleave |
Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. |
| dragover |
Fires on the target element continuously while the user drags the object over a valid drop target. |
| drop |
Fires on the target object when the mouse button is released during a drag-and-drop operation. |
| error |
Fires when an error occurs during object loading. |
| focus |
Fires when the object receives focus. |
| input |
Occurs when the text content of an element is changed through the user interface. |
| load |
Fires immediately after the client loads the object. |
| onencrypted |
This event is fired when the browser encounters Initialization Data in the media data. |
| onmsneedkey |
Deprecated. Occurs when a key is needed to decrypt the media data. |
| onselect |
Fires when the current selection changes. |
| reset |
Fires when the user resets a form. |
| scroll |
Fires when the user repositions the scroll box in the scroll bar on the object. |
Methods
The media object has these methods.
| Method | Description |
|---|---|
| addTextTrack |
Create a new TextTrack object to add to an HTML5 video. |
| canPlayType |
Returns a string that specifies whether the client can play a given media resource type. |
| compareDocumentPosition |
Compares the position of two nodes in a document. |
| getAttributeNodeNS |
Gets an attribute object that matches the specified namespace and name. |
| getAttributeNS |
Gets the value of the specified attribute within the specified namespace. |
| getElementsByClassName |
Gets a collection of objects that are based on the value of the class attribute. |
| getElementsByTagNameNS |
Gets a collection of objects that are based on the specified element names within a specified namespace. |
| hasAttributeNS |
Determines whether an attribute that has the specified namespace and name exists. |
| isDefaultNamespace |
Indicates whether or not a namespace is the default namespace for a document. |
| isEqualNode |
Determines if two nodes are equal. |
| isSameNode |
Determines if two node references refer to the same node. |
| isSupported |
Returns a value indicating whether or not the object supports a specific DOM standard. |
| load |
Resets the audio or video object and loads a new media resource. |
| lookupNamespaceURI |
Gets the URI of the namespace associated with a namespace prefix, if any. |
| lookupPrefix |
Gets the namespace prefix associated with a URI, if any. |
| msClearEffects |
Clears all effects from the media pipeline. |
| msInsertAudioEffect |
Inserts the specified audio effect into media pipeline. |
| msMatchesSelector |
Determines whether an object matches the specified selector. |
| msSetMediaProtectionManager |
Specifies the media protection manager for a given media pipeline. |
| pause |
Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. |
| play |
Loads and starts playback of a media resource. |
| removeAttributeNS |
Removes the specified attribute from the object. |
| setAttributeNodeNS |
Sets an attribute object as part of the object. |
| setAttributeNS |
Sets the value of the specified attribute within the specified namespace. |
| setMediaKeys |
Provides the MediaKeys to use when decrypting media during playback. |
Properties
The media object has these properties.
| Property | Access type | Description |
|---|---|---|
|
Read-only |
Returns an AudioTrackList object with the audio tracks for a given video element. | |
|
Use the preload element instead. The autobuffer property was initially listed in the W3C spec, but has been dropped. No version of Internet Explorer supports it. | ||
|
Gets or sets a value that indicates whether to start playing the media automatically. | ||
|
Gets a collection of buffered time ranges. | ||
|
Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). | ||
|
Read/write |
Specifies whether to use Cross-Origin Resource Sharing (CORS) when fetching an image from a site outside the webpage's domain. | |
|
Gets the address or URL of the current media resource (video,audio) that is selected by IHTMLMediaElement. | ||
|
Gets or sets the current playback position, in seconds. | ||
|
Get or sets the current state of the muted attribute. | ||
|
Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. | ||
|
Returns the duration in seconds of the current media resource. A | ||
|
Gets information about whether the playback has ended or not. | ||
|
Returns an object representing the current error state of the audio or video element. | ||
|
Gets the earliest possible position, in seconds, that the playback can begin. The initialTime property was initially listed in the W3C specification, but has been dropped. No new version of Internet Explorer supports it. | ||
|
Retrieves the local name of the fully qualified XML declaration for a node. | ||
|
Gets or sets a flag to specify whether playback should restart after it completes. | ||
|
Read-only |
The MediaKeys being used when decrypting encrypted media data | |
|
Read/write |
Specifies the purpose of the audio or video media, such as background audio or alerts. | |
|
Read/write |
Specifies the output device id that the audio will be sent to. | |
|
Read-only |
Returns an object which provides information on protected video playback. | |
|
Read-only |
Deprecated. Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. | |
|
Read/write |
Gets or sets whether the DLNA PlayTo device is available. | |
|
Read/write |
Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. | |
|
Read/write |
Gets or sets the primary DLNA PlayTo device. | |
|
Read-only |
Gets the source associated with the media element for use by the PlayToManager. | |
|
Read/write |
Specifies whether or not to enable low-latency playback on the media element. | |
|
Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. | ||
|
Retrieves the namespace URI of the fully qualified XML declaration for a node. | ||
|
Gets the current network activity for the element. | ||
|
Gets a flag that specifies whether playback is paused. | ||
|
Read-only |
Gets the quality information about the media element currently playing. | |
|
Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. | ||
|
Gets TimeRanges for the current media resource that has been played. | ||
|
Retrieves the local name of the fully qualified XML declaration for a node. | ||
|
Gets or sets a hint to how much buffering is advisable for a media resource, even if autoplay isn't specified. | ||
|
Read-only | ||
|
Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. | ||
|
Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. | ||
|
The address or URL of the a media resource (video, audio) that is to be considered. | ||
|
Holds the MediaStream that provides media for this element. | ||
|
Sets or retrieves the text content of an object and any child objects. | ||
|
Gets or sets the volume level for audio portions of the media element. |
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.8.10
See also

