files/en-us/web/api/htmlmediaelement/index.md
{{APIRef("HTML DOM")}}
The HTMLMediaElement interface adds to {{domxref("HTMLElement")}} the properties and methods needed to support basic media-related capabilities that are common to audio and video.
The {{domxref("HTMLVideoElement")}} and {{domxref("HTMLAudioElement")}} elements both inherit this interface.
{{InheritanceDiagram}}
This interface also inherits properties from its ancestors {{domxref("HTMLElement")}}, {{domxref("Element")}}, {{domxref("Node")}}, and {{domxref("EventTarget")}}.
{{domxref("HTMLMediaElement.audioTracks")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.autoplay")}}
: A boolean value that reflects the autoplay HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption.
[!NOTE] Automatically playing audio when the user doesn't expect or desire it is a poor user experience and should be avoided in most cases, though there are exceptions. See the Autoplay guide for media and Web Audio APIs for more information. Keep in mind that browsers may ignore autoplay requests, so you should ensure that your code isn't dependent on autoplay working.
{{domxref("HTMLMediaElement.buffered")}} {{ReadOnlyInline}}
buffered property is accessed.{{domxref("HTMLMediaElement.controls")}}
controls HTML attribute, indicating whether user interface items for controlling the resource should be displayed.{{domxref("HTMLMediaElement.controlsList")}}
DOMTokenList takes one or more of three possible values: nodownload, nofullscreen, and noremoteplayback.{{domxref("HTMLMediaElement.crossOrigin")}}
{{domxref("HTMLMediaElement.currentSrc")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.currentTime")}}
{{domxref("HTMLMediaElement.defaultMuted")}}
muted HTML attribute, which indicates whether the media element's audio output should be muted by default.{{domxref("HTMLMediaElement.defaultPlaybackRate")}}
double indicating the default playback rate for the media.{{domxref("HTMLMediaElement.disableRemotePlayback")}}
{{domxref("HTMLMediaElement.duration")}} {{ReadOnlyInline}}
NaN. If the media is of indefinite length (such as streamed live media, a WebRTC call's media, or similar), the value is Infinity.{{domxref("HTMLMediaElement.ended")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.error")}} {{ReadOnlyInline}}
null if there has not been an error.{{domxref("HTMLMediaElement.loop")}}
loop HTML attribute, which indicates whether the media element should start over when it reaches the end.{{domxref("HTMLMediaElement.mediaKeys")}} {{ReadOnlyInline}} {{SecureContext_Inline}}
null.{{domxref("HTMLMediaElement.muted")}}
true if the audio is muted and false otherwise.{{domxref("HTMLMediaElement.networkState")}} {{ReadOnlyInline}}
unsigned short (enumeration) indicating the current state of fetching the media over the network.{{domxref("HTMLMediaElement.paused")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.playbackRate")}}
double that indicates the rate at which the media is being played back.{{domxref("HTMLMediaElement.played")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.preload")}}
preload HTML attribute, indicating what data should be preloaded, if any. Possible values are: none, metadata, auto.{{domxref("HTMLMediaElement.preservesPitch")}}
false, the pitch will adjust to the speed of the audio.{{domxref("HTMLMediaElement.readyState")}} {{ReadOnlyInline}}
unsigned short (enumeration) indicating the readiness state of the media.{{domxref("HTMLMediaElement.remote")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.seekable")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.seeking")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.sinkId")}} {{ReadOnlyInline}} {{SecureContext_Inline}}
{{domxref("HTMLMediaElement.src")}}
src HTML attribute, which contains the URL of a media resource to use.{{domxref("HTMLMediaElement.srcObject")}}
HTMLMediaElement, or null if not assigned.{{domxref("HTMLMediaElement.textTracks")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.videoTracks")}} {{ReadOnlyInline}}
{{domxref("HTMLMediaElement.volume")}}
double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest).These properties are obsolete and should not be used, even if a browser still supports them.
null if none is assigned.mediagroup HTML attribute, which indicates the name of the group of elements it belongs to. A group of media elements shares a common {{domxref('MediaController')}}.double that provides access to the fragment end time if the media element has a fragment URI for currentSrc, otherwise it is equal to the media duration.This interface also inherits methods from its ancestors {{domxref("HTMLElement")}}, {{domxref("Element")}}, {{domxref("Node")}}, and {{domxref("EventTarget")}}.
codecs parameter included), canPlayType() returns the string probably if the media should be playable, maybe if there's not enough information to determine whether the media will play or not, or an empty string if the media cannot be played.src attribute or the {{HTMLElement("source")}} element.These methods are obsolete and should not be used, even if a browser still supports them.
{key: value} pairs. A separate copy of the data is returned each time the method is called. This method must be called after the loadedmetadata event fires.Inherits events from its parent, {{domxref("HTMLElement")}}.
Listen to these events using {{domxref("EventTarget.addEventListener", "addEventListener()")}} or by assigning an event listener to the oneventname property of this interface.
paused property is changed from true to false, as a result of the {{domxref("HTMLMediaElement.play()")}} method, or the autoplay attribute.{{Specifications}}
{{Compat}}
HTMLMediaElement