Availability | Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. |
An abstract superclass for media classes that display audio or video in webpages. This class defines common properties and methods inherited by the HTMLAudioElement
and HTMLVideoElement
classes representing the HTML audio
and video
elements.
The different types of media events that can occur are described in Table 1.
Event | Description |
---|---|
| Sent when the browser stops fetching the media data before the media resource was completely downloaded. |
| Sent when the browser can resume playback of the media data, but estimates that if playback is started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content. |
| Sent when the browser estimates that if playback is started now, the media resource could be rendered at the current playback rate all the way to its end without having to stop for further buffering. |
| Sent when the |
| Sent when the media element network state changes to the |
| Sent when playback has stopped at the end of the media resource and the |
| Sent when an error occurs while fetching the media data. Use the |
| Sent when the browser can render the media data at the current playback position for the first time. |
| Sent when the browser knows the duration and dimensions of the media resource. |
| Sent when the browser begins loading the media data. |
| Sent when playback pauses after the |
| Sent when playback starts after the |
| Sent when playback starts. |
| Sent when the browser is fetching the media data. |
| Sent when either the |
| Sent when the |
| Sent when the |
| Sent when the browser is fetching media data but it has stopped arriving. |
| Sent when the browser suspends loading the media data and does not have the entire media resource downloaded. |
| Sent when the |
| Sent when either the |
| Sent when the browser stops playback because it is waiting for the next frame. |
buffered
currentSrc
duration
ended
error
networkState
paused
played
readyState
seekable
seeking
startTime
A Boolean value that gives a hint to the browser that it should automatically buffer media when the webpage is loaded.
attribute boolean autobuffer;
If true
(the default), the media data is automatically buffered; otherwise, it is not.
A Boolean value that determines whether the media resource plays automatically when available.
attribute boolean autoplay;
If false
(the default), the media resource does not automatically play when loaded; otherwise, it does.
The time ranges of the media resource that have been downloaded. (read-only)
readonly attribute TimeRanges buffered;
A Boolean value that determines whether the playback controls appear.
attribute boolean controls;
On the desktop, if false
(the default), the playback controls do not appear; otherwise, they do appear. On iPhone OS, a native application is used to playback video in full screen; therefore, this property is ignored.
The absolute URL of the media resource. (read-only)
readonly attribute DOMString currentSrc;
This property is an empty string if the networkState
property is NETWORK_EMPTY
.
The current playback position in seconds.
attribute float currentTime setter raises (DOMException);
When you set this property, the media play head moves to the new location. An INVALID_STATE_ERR
DOM exception is raised if there is no selected media resource when you set this property. An INDEX_SIZE_ERR
DOM exception is raised if the specified time is not within the start and end times.
The default rate used to play the media resource.
attribute float defaultPlaybackRate;
The value of this property is a multiple of the media resource’s intrinsic speed. The default value is 1.0
.
The length of the media resource in seconds. (read-only)
readonly attribute float duration;
This property is 0
if there is no media data available. This property is NaN
if the duration is unknown. The value is positive infinity if the duration is known but is indefinite—for example, a live stream.
A Boolean value that indicates whether the media played to the end. (read-only)
readonly attribute boolean ended;
If true
, the video played to the end; otherwise, it did not.
The last error that occurred for this element. (read-only)
readonly attribute MediaError error;
A Boolean value that determines whether the playback should loop.
attribute boolean loop;
If true
, the playback should loop; otherwise, it should not.
A Boolean value that determines whether the audio content should be muted.
attribute boolean muted;
If true
, the audio track is muted; otherwise, it is not.
The state of downloading the media resource. (read-only)
readonly attribute unsigned short networkState;
Possible values are described in “Constants.”
A Boolean value that indicates whether the media is paused. (read-only)
readonly attribute boolean paused;
If true
, the video is paused; otherwise, it is not.
The speed that the media resource is playing.
attribute float playbackRate;
The value of this property is a multiple of the media resource’s intrinsic speed. If set to 0.0
, a NOT_SUPPORTED_ERR
DOM exception is raised. The default value is 1.0
.
The ranges of the media resource that was played. (read-only)
readonly attribute TimeRanges played;
The ready state of the media resource. (read-only)
readonly attribute unsigned short readyState;
Possible values are described in “Constants.”
The ranges that can be played in a nonlinear fashion. (read-only)
readonly attribute TimeRanges seekable;
A Boolean value that indicates whether the element is seeking. (read-only)
readonly attribute boolean seeking;
If true
, the media resource is playing in a nonlinear fashion; otherwise, it is not.
The URI address of the media resource to play.
attribute DOMString src;
The earliest possible time in seconds to start playback. (read-only)
readonly attribute float startTime;
The volume of the audio portion of the media element.
attribute float volume setter raises (DOMException);
The value of this property must be in the range from 0.0
(silent) to 1.0
(loudest); otherwise, a INDEX_SIZE_ERR
DOM exception is raised. The default value is 1.0
.
Returns whether the media element supports the specified MIME type.
DOMString canPlayType(in DOMString type);
The possible string values are: “no”, “probably” and “maybe”.
Starts loading the media resource.
void load() raises (DOMException);
Pauses the media playback if in progress.
void pause();
Begins playing the media resource.
void play();
If the media resource is not available for playback, this method loads it.
Possible values for the readyState
property.
Possible values for the networkState
property.
Constant | Description | |
---|---|---|
NETWORK_EMPTY | The element is not initialized.
Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. | |
NETWORK_IDLE | The network connection is idle.
Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. | |
NETWORK_LOADING | The media resource is loading.
Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. | |
NETWORK_LOADED | The media source finished loading.
Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. | |
NETWORK_NO_SOURCE | No media resource was found.
Available in Safari 3.1 and later. Available in iPhone OS 3.0 and later. |
Last updated: 2010-05-11