MediaElement

EventTargetNodeDOMElementElementjs.html.MediaElement (extern class) → AudioElement, VideoElement

The HTMLMediaElement interface adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video.

Documentation HTMLMediaElement by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Static Members

NETWORK_EMPTY: Int

NETWORK_IDLE: Int

NETWORK_LOADING: Int

NETWORK_NO_SOURCE: Int

HAVE_NOTHING: Int

HAVE_METADATA: Int

HAVE_CURRENT_DATA: Int

HAVE_FUTURE_DATA: Int

HAVE_ENOUGH_DATA: Int

Instance Members

Returns a MediaError object for the most recent error, or null if there has not been an error.


src: String

Is a DOMString that reflects the src HTML attribute, which contains the URL of a media resource to use.


currentSrc: String

Returns a DOMString with the absolute URL of the chosen media resource.


crossOrigin: String

Is a DOMString indicating the CORS setting for this media element.


networkState: Int

Returns a unsigned short (enumeration) indicating the current state of fetching the media over the network.


preload: String

Is a DOMString that reflects the preload HTML attribute, indicating what data should be preloaded, if any. Possible values are: none, metadata, auto.


buffered: TimeRanges

Returns a TimeRanges object that indicates the ranges of the media source that the browser has buffered (if any) at the moment the buffered property is accessed.


readyState: Int

Returns a unsigned short (enumeration) indicating the readiness state of the media.


seeking: Bool

Returns a Boolean that indicates whether the media is in the process of seeking to a new position.


currentTime: Float

Is a double indicating the current playback time in seconds. Setting this value seeks the media to the new time.


duration: Float

Returns a double indicating the length of the media in seconds, or 0 if no media data is available.


paused: Bool

Returns a Boolean that indicates whether the media element is paused.


defaultPlaybackRate: Float

Is a double indicating the default playback rate for the media.


playbackRate: Float

Is a double that indicates the rate at which the media is being played back.


played: TimeRanges

Returns a TimeRanges object that contains the ranges of the media source that the browser has played, if any.


seekable: TimeRanges

Returns a TimeRanges object that contains the time ranges that the user is able to seek to, if any.


ended: Bool

Returns a Boolean that indicates whether the media element has finished playing.


autoplay: Bool

A Boolean that reflects the autoplay HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption. Sites which automatically play audio (or videos with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control.


loop: Bool

Is a Boolean that reflects the loop HTML attribute, which indicates whether the media element should start over when it reaches the end.


controls: Bool

Is a Boolean that reflects the controls HTML attribute, indicating whether user interface items for controlling the resource should be displayed.


volume: Float

Is a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest).


muted: Bool

Is a Boolean that determines whether audio is muted. true if the audio is muted and false otherwise.


defaultMuted: Bool

Is a Boolean that reflects the muted HTML attribute, which indicates whether the media element's audio output should be muted by default.


audioTracks: AudioTrackList

A AudioTrackList that lists the AudioTrack objects contained in the element.


videoTracks: VideoTrackList

Returns the list of VideoTrack objects contained in the element.

Gecko supports only single track playback, and the parsing of tracks' metadata is only available for media with the Ogg container format.


textTracks: TextTrackList

Returns the list of TextTrack objects contained in the element.


srcObject: MediaStream

Is a MediaStream representing the media to play or that has played in the current HTMLMediaElement, or null if not assigned.


Returns a MediaKeys object or null. MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback.


onencrypted: haxe.Function

Sets the EventHandler called when the media is encrypted.


onwaitingforkey: haxe.Function

Sets the EventHandler called when playback is blocked while waiting for an encryption key.


load(): Void

Resets the media element and restarts the media resource. Any pending events are discarded. How much media data is fetched is still affected by the preload attribute. This method can be useful for releasing resources after any src attribute and source element descendants have been removed. Otherwise, it is usually unnecessary to use this method, unless required to rescan source element children after dynamic changes.


canPlayType(type: String): String

Determines whether the specified media type can be played back.

Name Type
type String
Returns
String

fastSeek(time: Float): Void

Directly seeks to the given time.

Name Type
time Float

Begins playback of the media.

Returns
js.lib.Promise<Void>

pause(): Void

Pauses the media playback.


addTextTrack(kind: TextTrackKind, ?label: String = "", ?language: String = ""): TextTrack

Adds a text track (such as a track for subtitles) to a media element.

Name Type Default
kind TextTrackKind
label String ""
language String ""
Returns
TextTrack

setMediaKeys(mediaKeys: js.html.eme.MediaKeys): js.lib.Promise<Void>

Returns Promise. Sets the MediaKeys keys to use when decrypting media during playback.

Name Type
mediaKeys js.html.eme.MediaKeys
Returns
js.lib.Promise<Void>