HTMLMediaElement
https://html.spec.whatwg.org/multipage/media.html#htmlmediaelement This object also emits few custom events other than standard events described in w3c specification. "playbackstarted" : event sent to the client when MediaPlayer start the playback "audiofocusgranted": event sent to the client when MediaPlayer resumes the playback internally on obtaining the audio focus. "audiofocuspaused" : event sent to the client when MediaPlayer pauses the playback internally on loosing the audio focus temporarily. "audiofocuslost" : event sent to the client when MediaPlayer pauses the playback internally on loosing the audio focus permanantly.
Extended by
MediaPlayerHTMLVideoElementHTMLAudioElement
Implements
Constructors
new HTMLMediaElement()
new HTMLMediaElement(): HTMLMediaElement
Returns
Properties
src
src:
string
Set the URL of the media source. For additional information, see https://html.spec.whatwg.org/multipage/media.html#location-of-the-media-resource.
srcObject
srcObject: MediaProvider
Set the source MediaProvider object.
For additional information, see
https://html.spec.whatwg.org/multipage/media.html#dom-media-srcobject.
error
readonlyerror: MediaError
Get the last media error encountered. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-error.
currentSrc
readonlycurrentSrc:string
Get the source URL of the current media being played. https://html.spec.whatwg.org/multipage/media.html#dom-media-currentsrc.
networkState
readonlynetworkState:number
https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate.
buffered
readonlybuffered: TimeRanges
Get the buffered time range of the content. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-buffered.
readyState
readonlyreadyState:number
Get the ready state of the media element. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-readystate.
seeking
readonlyseeking:boolean
Check whehter the media element is currently seeking. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-seeking.
duration
readonlyduration:number
Get the duration of the content being played. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-duration.
paused
readonlypaused:boolean
Check whether the media playback is paused or not. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-paused.
played
readonlyplayed: TimeRanges
https://html.spec.whatwg.org/multipage/media.html#dom-media-played
seekable
readonlyseekable: TimeRanges
Get the seekable time range of the content. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-seekable.
ended
readonlyended:boolean
Check whehter the media playback has ended. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-ended.
preload
preload:
string
https://html.spec.whatwg.org/multipage/media.html#attr-media-preload
currentTime
currentTime:
number
Get or set the current time of the playback. Setting the current time leads to a seek operation. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-currenttime.
defaultPlaybackRate
defaultPlaybackRate:
number
https://html.spec.whatwg.org/multipage/media.html#dom-media-defaultplaybackrate
playbackRate
playbackRate:
number
https://html.spec.whatwg.org/multipage/media.html#dom-media-playbackrate
autoplay
autoplay:
boolean
If set to true, automatically starts the playback when the URL is loaded.
If set to false, the app must call play explicitly to start playback.
For additional information, see
https://html.spec.whatwg.org/multipage/media.html#dom-media-autoplay.
loop
loop:
boolean
https://html.spec.whatwg.org/multipage/media.html#dom-media-loop
controls?
optionalcontrols:boolean | undefined
Enable or disable the UI for media controls. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-controls.
volume
volume:
number
https://html.spec.whatwg.org/multipage/media.html#dom-media-volume
muted
muted:
boolean
https://html.spec.whatwg.org/multipage/media.html#dom-media-muted
defaultMuted
defaultMuted:
boolean
https://html.spec.whatwg.org/multipage/media.html#dom-media-defaultmuted
audioTracks
readonlyaudioTracks: AudioTrackList
Gets the list of audio tracks. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-audiotracks.
videoTracks
readonlyvideoTracks: VideoTrackList
Gets the list of video tracks. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-videotracks.
textTracks
readonlytextTracks: TextTrackList
Gets the list of text tracks. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-texttracks.
mediaKeys?
readonlyoptionalmediaKeys: MediaKeys| undefined
The media keys to use to decrypt DRM protected content. For additional information, see https://www.w3.org/TR/encrypted-media/#dom-htmlmediaelement-mediakeys.
nodeName
readonlynodeName:string
For additional information, see https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName.
HAVE_NOTHING
staticreadonlyHAVE_NOTHING:number=0
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-have_nothing.
HAVE_METADATA
staticreadonlyHAVE_METADATA:number=1
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-have_metadata.
HAVE_CURRENT_DATA
staticreadonlyHAVE_CURRENT_DATA:number=2
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-have_current_data.
HAVE_FUTURE_DATA
staticreadonlyHAVE_FUTURE_DATA:number=3
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-have_future_data.
HAVE_ENOUGH_DATA
staticreadonlyHAVE_ENOUGH_DATA:number=4
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-have_enough_data.
NETWORK_EMPTY
staticreadonlyNETWORK_EMPTY:number=0
https://html.spec.whatwg.org/multipage/media.html#dom-media-network_empty.
NETWORK_IDLE
staticreadonlyNETWORK_IDLE:number=1
https://html.spec.whatwg.org/multipage/media.html#dom-media-network_idle.
NETWORK_LOADING
staticreadonlyNETWORK_LOADING:number=2
https://html.spec.whatwg.org/multipage/media.html#dom-media-network_loading.
NETWORK_NO_SOURCE
staticreadonlyNETWORK_NO_SOURCE:number=3
https://html.spec.whatwg.org/multipage/media.html#dom-media-network_no_source.
defaultSeekIntervalInSec
defaultSeekIntervalInSec:
number
Configure the default seek interval in second for remote control media key press "fast-forward" or "rewind" functionality
Methods
addEventListener()
abstractaddEventListener(type:string, listener: EventListener, options?:boolean | AddEventListenerOptions | undefined):void
Parameters
type
string
listener
options?
boolean | AddEventListenerOptions | undefined
addTextTrack()
abstractaddTextTrack(kind: TextTrackKind, label?:string | undefined, language?:string | undefined, uri?:string | undefined, mimeType?:string | undefined): TextTrack
For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-addtexttrack.
Parameters
kind
The kind parameter must return the text track kind of the text track that the TextTrack object represents.
label?
string | undefined
The label parameter must return the text track label of the text track that the TextTrack object represents.
language?
string | undefined
The language parameter must return the text track language of the text track that the TextTrack object represents.
uri?
string | undefined
The uri parameter must return the URI of the out of band subtitle of the text track that the TextTrack object represents.
This is a custom addition (not part of the w3c specification). If you specify the uri parameter, the component parses and renders subtitles.
mimeType?
string | undefined
The mimeType parameter must return the mime type of the out of band subtitle of the text track that the TextTrack
object represents. This is a custom addition (not part of the w3c specification).
Returns
canPlayType()
abstractcanPlayType(type:string): CanPlayTypeResult
https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype
Parameters
type
string
mime type
Returns
fastSeek()
abstractfastSeek(time:number):void
https://html.spec.whatwg.org/multipage/media.html#dom-media-fastseek
Parameters
time
number
getStartDate()
abstractgetStartDate():Date
https://html.spec.whatwg.org/multipage/media.html#dom-media-getstartdate
Returns
Date
load()
abstractload():void
https://html.spec.whatwg.org/multipage/media.html#dom-media-load
pause()
abstractpause():void
Pauses the playback. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-pause.
play()
abstractplay():void
Starts the playback. For additional information, see https://html.spec.whatwg.org/multipage/media.html#dom-media-play.
removeEventListener()
abstractremoveEventListener(type:string, listener: EventListener, options?:boolean | EventListenerOptions | undefined):void
Parameters
type
string
listener
options?
boolean | EventListenerOptions | undefined
setMediaKeys()
abstractsetMediaKeys(mediaKeys?: MediaKeys| undefined):Promise<void>
Sets the media keys used for decrypting DRM protected content. For additional information, see https://www.w3.org/TR/encrypted-media/#dom-htmlmediaelement-setmediakeys
Parameters
mediaKeys?
MediaKeys | undefined
For additional information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeys.
Returns
Promise<void>
Last updated: Jul 22, 2026

