Represents an sound or audio stream.
Platform Support
| Mozilla | Chrome | Safari | Opera | IE | Netscape | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|---|
Constructors
| Constructor | Action | Mozilla | Chrome | Safari | Opera | IE | Netscape | ||
|---|---|---|---|---|---|---|---|---|---|
|
HTMLAudioElement Constructor() : HTMLAudioElement
Audio in an HTML document.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | ||
HTMLAudioElement() : HTMLAudioElementAudio in an HTML document. Returns
|
|||||||||
Inherited Properties
| Property | Action | Mozilla | Chrome | Safari | Opera | IE | Netscape |
|---|---|---|---|---|---|---|---|
|
error
: MediaError
Returns a MediaError object representing the current error state of the element.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
src
: String
Gives the address of the media resource (video, audio) to show.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
currentSrc
: String
Guves the current address of the media resource (video, audio) to show.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
NETWORK_EMPTY
: Number
The element has not yet been initialized. All attributes are in their initial states. (numeric value 0)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
NETWORK_IDLE
: Number
The element's resource selection algorithm is active and has selected a resource, but it is not actually using the network
at this time.(numeric value 1)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
NETWORK_LOADING
: Number
The user agent is actively trying to download data.(numeric value 2)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
NETWORK_NO_SOURCE
: Number
The element's resource selection algorithm is active, but it has failed to find a resource to use.(numeric value 3)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
networkState
: Number
The state of the network.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
preload
: String
Provides a hint to the user agent about what the author thinks will lead to the best user experience.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
buffered
: TimeRanges
Returns a new instance 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.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
HAVE_NOTHING
: Number
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. (numeric value 0)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
HAVE_METADATA
: Number
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 raise an exception when seeking. No media data is available
for the immediate current playback position. The timed tracks are ready.(numeric value 1)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
HAVE_CURRENT_DATA
: Number
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.(numeric value 2)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
HAVE_FUTURE_DATA
: Number
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.(numeric
value 3)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
HAVE_ENOUGH_DATA
: Number
All the conditions described for the HAVE_FUTURE_DATA state are met, and, in addition, the user agent estimates that data
is being fetched at a rate where the current playback position, if it were to advance at the rate given by the defaultPlaybackRate
attribute, would not overtake the available data before playback reaches the end of the media resource.(numeric value 4)
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
readyState
: Number
Returns the value that describes the current ready state of the media element.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
seeking
: Boolean
Specifies whether the user is currently seeking.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
currentTime
: Number
The current playback position, expressed in seconds.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
startTime
: Number
The earliest possible position, expressed in seconds.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
duration
: Number
The length of the media resource, expressed in seconds.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
paused
: Number
Represents whether the media element is paused or not.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
defaultPlaybackRate
: Number
The desired speed at which the media resource is to play, as a multiple of its intrinsic speed.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
playbackRate
: Number
The speed at which the media resource is to play, as a multiple of its intrinsic speed.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
played
: TimeRanges
A new instance normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent
has so far rendered, at the time the attribute is evaluated.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
seekable
: TimeRanges
A new instance 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.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
ended
: Boolean
Returns true if the media element has ended playback and the direction of playback is forwards, and false otherwise.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
autoplay
: Boolean
When present, the user agent (as described in the algorithm described herein) will automatically begin playback of the media
resource as soon as it can do so without stopping.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
loop
: Boolean
Indicates that the media element is to seek back to the start of the media resource upon reaching the end.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
controls
: Boolean
If present, it indicates that the author has not provided a scripted controller and would like the user agent to provide its
own set of controls.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
volume
: Number
The playback volume of any audio portions of the media element, in the range 0.0 (silent) to 1.0 (loudest).
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
muted
: Boolean
Returns true if the audio channels are muted and false otherwise.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
|
tracks
: Array
Return an array host object for objects of type TimedTrack that is fixed length and read only.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no |
|
|||||||
Inherited Functions
| Method | Action | Mozilla | Chrome | Safari | Opera | IE | Netscape | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
load() :
void
Causes the element to reset and start selecting and loading a new media resource from scratch.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | |||||||||||
|
||||||||||||||||||
|
play() :
void
Sets the paused attribute to false, loading the media resource and beginning playback if necessary. If the playback had ended,
will restart it from the start.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | |||||||||||
|
||||||||||||||||||
|
pause() :
void
Sets the paused attribute to true, loading the media resource if necessary.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | |||||||||||
|
||||||||||||||||||
|
canPlayType(Number type) : DOMString
Returns the empty string (a negative response), "maybe", or "probably" based on how confident the user agent is that it can
play media resources of the given type.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | |||||||||||
|
Parameters
Returns
|
||||||||||||||||||
|
addTrack(String label, String kind, String language) : MutableTimedTrack
Creates and returns a new MutableTimedTrack object, which is also added to the media element's list of timed tracks.
|
Show Details | 3.5+ | no | 4.0.5+ | 10.5+ | 9.0+ | no | |||||||||||
|
Parameters
Returns
|
||||||||||||||||||
References
Availability
JavaScript 1.2|WhatWG