class js.html.MediaElement extends Element
Available on js
Sub classes | ||||||
![]() | AudioElement, VideoElement |
|
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.
Documentation for this class was provided by MDN.
Class Fields
static var HAVE_CURRENT_DATA:Int
Data is available for the current playback position, but not enough to actually play more than one frame.
static var HAVE_ENOUGH_DATA:Int
Enough data is available—and the download rate is high enough—that the media can be played through to the end without interruption.
static var HAVE_FUTURE_DATA:Int
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).
static var HAVE_METADATA:Int
Enough of the media resource has been retrieved that the metadata attributes are initialized. Seeking will no longer raise an exception.
Instance Fields
Reflects the
autoplay
HTML attribute, indicating whether to begin playing as soon as enough media is available.Reflects the
controls
HTML attribute, indicating whether user interface items for controlling the resource should be displayed.var currentSrc:String
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
.
var currentTime:Float
The current playback time, in seconds. Setting this value seeks the media to the new time. Setter throws DOMException.
var defaultMuted:Bool
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).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 NOTSUPPORTEDERR
exception.
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
.
var error:MediaError
The media error object for the most recent error, or null if there has not been an error.
Reflects the
loop
HTML attribute, indicating whether the media element should start over when it reaches the end.var networkState:Int
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. |
var 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.
Reflects the
preload
HTML attribute, indicating what data should be preloaded at page-load time, if any.var readyState:Int
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. |