Table of contents
- 1. Method overview
- 2. Attributes
- 3. Methods
- 3.1. canPlayType()
- 3.2. load()
- 3.3. mozLoadFrom()
- 3.4. pause()
- 3.5. play()
- 4. See also
nsIDOMHTMLAudioElement
and
nsIDOMHTMLVideoElement
interfaces, which in turn implement the
<audio> and
<video> HTML5 elements.
nsIDOMHTMLElement
Last changed in Gecko 2.0
(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
Method overview
DOMString canPlayType(in DOMString type); |
void load(); |
void mozLoadFrom(in nsIDOMHTMLMediaElement other);
Requires Gecko 1.9.2
Non-standard |
void pause(); |
void play(); |
Attributes
| Attribute | Type | Description | ||||||||||||||||||
autobuffer
Obsolete since Gecko 2.0
| boolean | true if the media should automatically begin to download, regardless of whether or not autoplay is true. Replaced with the preload attribute in Gecko 2.0
(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
. | ||||||||||||||||||
autoplay | boolean | true if playback should automatically begin as soon as enough media is available to do so without interruption. | ||||||||||||||||||
buffered
Requires Gecko 2.0
| TimeRanges | A static, normalized
nsIDOMHTMLTimeRanges
object describing the time ranges of the media that have been buffered. Read only. | ||||||||||||||||||
bufferedBytes | ByteRanges | A static, normalized ByteRanges object describing the byte ranges of the media that have been buffered. Read only.
Unimplemented
| ||||||||||||||||||
bufferingRate | float | The average number of bits per second for the current download over the past few seconds. If there is no download in progress, this value is 0.0. Read only. Unimplemented | ||||||||||||||||||
bufferingThrottled | boolean | true if Firefox is intentionally throttling the bandwidth used by the download (such as when the download is paused), otherwise false. Read only.
Unimplemented
| ||||||||||||||||||
controls | boolean | true if user interface for controlling the media should be presented. | ||||||||||||||||||
currentSrc | DOMString | The absolute URL of the chosen media resource (if, for example, the server selects a media file based on the resolution of the user's display), or an empty string if the networkState is EMPTY. Read only. | ||||||||||||||||||
currentTime | float | The current playback time, in seconds. Setting this value will seek the media to the new time. | ||||||||||||||||||
defaultPlaybackRate | float | The default playback rate for the media. The Ogg backend does not support this. 1.0 is "normal speed," values lower than 1.0 make the media play slower than normal, higher values make it play faster. The value 0.0 is invalid and throws a NOT_SUPPORTED_ERR exception. | ||||||||||||||||||
duration | float | The length of the media in seconds, or zero if no media data is available. If the media data is available but the length is unknown, this value is NaN. If the media is streamed and has no predefined length, the value is Inf. Read only. | ||||||||||||||||||
ended | boolean | true if playback has finished. Read only. | ||||||||||||||||||
error |
| The media's error status. Read only. | ||||||||||||||||||
mozFrameBufferLength
Requires Gecko 2.0
Non-standard | unsigned long | The size, in bytes, of the frame buffer used by the audio stream. The default size for a media element with audio is mozChannels * 1024. The size must be between 512 and 16,384 bytes. | ||||||||||||||||||
mozSampleRate
Requires Gecko 2.0
Non-standard | unsigned long | The audio sample rate. Read only. | ||||||||||||||||||
mozChannels
Requires Gecko 2.0
Non-standard | unsigned long | The number of channels of audio. Read only. | ||||||||||||||||||
muted | boolean | true if the audio is muted, otherwise false. | ||||||||||||||||||
networkState | unsigned short | The current state of the fetch of the media. Read only.
| ||||||||||||||||||
paused | boolean | true if the media playback is currently paused. Read only. | ||||||||||||||||||
playbackRate | float | The current rate at which the media is being played back. This is used to implement user controls for fast forward, slow motion, and so forth. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed. Not supported by the Ogg backend. | ||||||||||||||||||
preload | DOMString | A string indicating what if any data should be preloaded at page load time.
An empty string is equivalent to the default, which is "auto". This value is a hint to the browser; it may be ignored or overridden. For example, specifying the Replaced the | ||||||||||||||||||
readyState | unsigned short | The media's current readiness state. Read only.
| ||||||||||||||||||
seeking | boolean | true if the media is in the process of seeking to a new position, otherwise false. Read only. | ||||||||||||||||||
src | DOMString | The URL of the media to present. | ||||||||||||||||||
totalBytes | unsigned long | The length, in bytes, of the media resource. If the length is unknown, or the content is streamed and therefore has no specified length, this value is 0. Read only. | ||||||||||||||||||
volume | float | The current audio volume, from 0.0 (silent) to 1.0 (maximum). |
Methods
canPlayType()
Determines whether or not the specified media type can be played back.
DOMString canPlayType( in DOMString type );
Parameters
- type
- The media type to test for, such as "video/ogg".
Return value
- "" if the specified type definitely cannot be played (since Gecko 1.9.1.2/ Firefox 3.5.2; was "no" in previous versions).
- "probably" if the specified type appears to be playable.
- "maybe" if it's impossible to be sure if the type can be played without actually attempting to do so.
Because media formats are complicated, and it's impossible to judge every possible detail from the type string, there is no such thing as 100% certain that the specified type can be played; the best you can do is "probably".
load()
Begins loading the media content from the server.
void load();
Parameters
None.
Requires Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)
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 that data downloaded by either element is available to both.
void mozLoadFrom( nsIDOMHTMLMediaElement other );
Parameters
other- An
nsIDOMHTMLMediaElementobject representing the element from which to load.
pause()
Pauses the media playback.
void pause();
Parameters
None.
play()
Begins playback of the media. If you have changed the "src" attribute of the video tag since the page was loaded, you must call load() before play(), otherwise the original video will play again.
void play();
Parameters
None.
See also
- Media elements (HTML 5 specification, editor's draft)
videoaudio- Manipulating audio using the enhanced audio API
- Using audio and video in Firefox
- Media formats supported by the audio and video elements

