Dart API Referencedart:htmlMediaElement

MediaElement Interface

HTML media elements (such as <audio> and <video> ) expose the HTMLMediaElement interface which provides special properties and methods (beyond the regular element object interface they also have available to them by inheritance) for manipulating the layout and presentation of media elements.

Extends

Element

Subinterfaces

AudioElement, VideoElement

Static Fields

Code final int EOS_DECODE_ERR #

static final int EOS_DECODE_ERR = 2;

Code final int EOS_NETWORK_ERR #

static final int EOS_NETWORK_ERR = 1;

Code final int EOS_NO_ERROR #

static final int EOS_NO_ERROR = 0;

Code final int HAVE_CURRENT_DATA #

static final int HAVE_CURRENT_DATA = 2;

Code final int HAVE_ENOUGH_DATA #

static final int HAVE_ENOUGH_DATA = 4;

Code final int HAVE_FUTURE_DATA #

static final int HAVE_FUTURE_DATA = 3;

Code final int HAVE_METADATA #

static final int HAVE_METADATA = 1;

Code final int HAVE_NOTHING #

static final int HAVE_NOTHING = 0;

Code final int NETWORK_EMPTY #

static final int NETWORK_EMPTY = 0;

Code final int NETWORK_IDLE #

static final int NETWORK_IDLE = 1;

Code final int NETWORK_LOADING #

static final int NETWORK_LOADING = 2;

Code final int NETWORK_NO_SOURCE #

static final int NETWORK_NO_SOURCE = 3;

Code final int SOURCE_CLOSED #

static final int SOURCE_CLOSED = 0;

Code final int SOURCE_ENDED #

static final int SOURCE_ENDED = 2;

Code final int SOURCE_OPEN #

static final int SOURCE_OPEN = 1;

Methods

Code TextTrack addTextTrack(String kind, [String label, String language]) #

TextTrack addTextTrack(String kind, [String label, String language]);

Code String canPlayType(String type, String keySystem) #

Determines whether the specified media type can be played back.
String canPlayType(String type, String keySystem);

Code void load() #

Begins loading the media content from the server.
void load();

Code MediaElementEvents get on() #

MediaElementEvents get on();

Code void pause() #

Pauses the media playback.
void pause();

Code void play() #

Begins playback of the media. If you have changed the src attribute of the media element since the page was loaded, you must call load() before play(), otherwise the original media plays again.
void play();

Code void webkitAddKey(String keySystem, Uint8Array key, [Uint8Array initData, String sessionId]) #

void webkitAddKey(String keySystem, Uint8Array key, [Uint8Array initData, String sessionId]);

Code void webkitCancelKeyRequest(String keySystem, String sessionId) #

void webkitCancelKeyRequest(String keySystem, String sessionId);

Code void webkitGenerateKeyRequest(String keySystem, [Uint8Array initData]) #

void webkitGenerateKeyRequest(String keySystem, [Uint8Array initData]);

Code void webkitSourceAbort(String id) #

void webkitSourceAbort(String id);

Code void webkitSourceAddId(String id, String type) #

void webkitSourceAddId(String id, String type);

Code void webkitSourceAppend(String id, Uint8Array data) #

void webkitSourceAppend(String id, Uint8Array data);

Code TimeRanges webkitSourceBuffered(String id) #

TimeRanges webkitSourceBuffered(String id);

Code void webkitSourceEndOfStream(int status) #

void webkitSourceEndOfStream(int status);

Code void webkitSourceRemoveId(String id) #

void webkitSourceRemoveId(String id);

Fields

Code bool autoplay #

Reflects the autoplay HTML attribute, indicating whether to begin playing as soon as enough media is available.
bool autoplay;

Code final TimeRanges buffered #

The ranges of the media source that the browser has buffered, if any.
final TimeRanges buffered;

Code MediaController controller #

MediaController controller;

Code bool controls #

Reflects the controls HTML attribute, indicating whether user interface items for controlling the resource should be displayed.
bool controls;

Code final String currentSrc #

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.
final String currentSrc;

Code num currentTime #

The current playback time, in seconds.  Setting this value seeks the media to the new time.
num currentTime;

Code bool defaultMuted #

Reflects the muted HTML attribute, indicating whether the media element's audio output should be muted by default. Changing the value dynamically will not unmute the audio (it only controls the default state).
bool defaultMuted;

Code num defaultPlaybackRate #

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.
num defaultPlaybackRate;

Code final num duration #

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.
final num duration;

Code final bool ended #

Indicates whether the media element has ended playback.
final bool ended;

Code final MediaError error #

The media error object for the most recent error, or null if there has not been an error.
final MediaError error;

Code final num initialTime #

final num initialTime;

Code bool loop #

Reflects the loop HTML attribute, indicating whether the media element should start over when it reaches the end.
bool loop;

Code String mediaGroup #

String mediaGroup;

Code bool muted #

true if the audio is muted, and false otherwise.
bool muted;

Code final int networkState #

The current state of fetching the media over the network.

Constant Value Description
EMPTY 0 There is no data yet.  The readyState is also HAVE_NOTHING.
LOADING 1 The media is loading.
LOADED_METADATA 2 The media's metadata has been loaded.
LOADED_FIRST_FRAME 3 The media's first frame has been loaded.
LOADED 4 The media has been fully loaded.
final int networkState;

Code final bool paused #

Indicates whether the media element is paused.
final bool paused;

Code num playbackRate #

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.
num playbackRate;

Code final TimeRanges played #

The ranges of the media source that the browser has played, if any.
final TimeRanges played;

Code String preload #

Reflects the preload HTML attribute, indicating what data should be preloaded at page-load time, if any.
String preload;

Code final int readyState #

The readiness state of the media:

Constant Value Description
HAVE_NOTHING 0 No information is available about the media resource.
HAVE_METADATA 1 Enough of the media resource has been retrieved that the metadata attributes are initialized.  Seeking will no longer raise an exception.
HAVE_CURRENT_DATA 2 Data is available for the current playback position, but not enough to actually play more than one frame.
HAVE_FUTURE_DATA 3 Data for the current playback position as well as for at least a little bit of time into the future is available (in other words, at least two frames of video, for example).
HAVE_ENOUGH_DATA 4 Enough data is available—and the download rate is high enough—that the media can be played through to the end without interruption.
final int readyState;

Code final TimeRanges seekable #

The time ranges that the user is able to seek to, if any.
final TimeRanges seekable;

Code final bool seeking #

Indicates whether the media is in the process of seeking to a new position.
final bool seeking;

Code String src #

Reflects the src HTML attribute, containing the URL of a media resource to use.
String src;

Code final num startTime #

The earliest possible position in the media, in seconds.
final num startTime;

Code final TextTrackList textTracks #

final TextTrackList textTracks;

Code num volume #

The audio volume, from 0.0 (silent) to 1.0 (loudest).
num volume;

Code final int webkitAudioDecodedByteCount #

final int webkitAudioDecodedByteCount;

Code bool webkitClosedCaptionsVisible #

bool webkitClosedCaptionsVisible;

Code final bool webkitHasClosedCaptions #

final bool webkitHasClosedCaptions;

Code final String webkitMediaSourceURL #

final String webkitMediaSourceURL;

Code bool webkitPreservesPitch #

bool webkitPreservesPitch;

Code final int webkitSourceState #

final int webkitSourceState;

Code final int webkitVideoDecodedByteCount #

final int webkitVideoDecodedByteCount;

This page includes content from the Mozilla Foundation that is graciously licensed under a Creative Commons: Attribution-Sharealike license. Mozilla has no other association with Dart or dartlang.org. We encourage you to improve the web by contributing to The Mozilla Developer Network.