HTMLMediaElement
================

La interfaz HTMLMediaElement añade a `HTMLElement` las propiedades y métodos necesarios para soportar las capacidades básicas relacionadas con los medios de comunicación que son comunes en audio y vídeo. Los elementos `HTMLVideoElement` y `HTMLAudioElement` heredan esta interfaz.

Properties
----------

Esta interfaz también hereda propiedades de sus antepasados `HTMLElement`, `Element`, `Node` y `EventTarget`.

`HTMLMediaElement.audioTracks` (en-US)

Un `AudioTrackList` (en-US) que lista los `AudioTrack` (en-US) objetos contenidos en el elemento.

`HTMLMediaElement.autoplay` (en-US)

Un `Booleano` que refleja el `autoplay`. Atributo HTML, que indica si la reproducción debe comenzar automáticamente tan pronto como haya suficiente material disponible para hacerlo sin interrupción.

**Nota:** Los sitios que reproducen automáticamente audio (o vídeos con una pista de audio) pueden ser una experiencia desagradable para los usuarios, por lo que deben evitarse en la medida de lo posible. Si debe ofrecer la funcionalidad de autojuego, debe hacer que se active (requiriendo que el usuario lo habilite específicamente). Sin embargo, esto puede ser útil a la hora de crear elementos multimedia cuya fuente se establecerá más adelante, bajo el control del usuario.

`HTMLMediaElement.buffered` (en-US) Read only 

Devuelve un objeto `TimeRanges` (en-US) que indica los rangos de la fuente de medios que el navegador ha almacenado en el búfer (si existe) en el momento en que se accede a la propiedad almacenada en el búfer.

`HTMLMediaElement.controller` (en-US)

Es un objeto `MediaController` que representa el controlador de medios asignado al elemento, o nulo si no se asigna ninguno.

`HTMLMediaElement.controls` (en-US)

Es un `booleano` que refleja el `controles`[1]. Atributo HTML, que indica si deben visualizarse las posiciones de la interfase de usuario para controlar el recurso.

`HTMLMediaElement.controlsList` (en-US) Read only 

Devuelve un `DOMTokenList` (en-US) que ayuda al agente de usuario a seleccionar qué controles mostrar en el elemento multimedia cuando el agente de usuario muestra su propio conjunto de controles. La DOMTokenList toma uno o más de los tres valores posibles: nodownload, nofullscreen y noremoteplayback.

`HTMLMediaElement.crossOrigin` (en-US)

Es un `DOMString` que indica la configuración CORS para este elemento multimedia.

`HTMLMediaElement.currentSrc` (en-US) Read only 

Devuelve un `DOMString` con la URL absoluta del recurso multimedia elegido.

`HTMLMediaElement.currentTime` (en-US)

Es un doble indicador del tiempo de reproducción actual en segundos. Fijar este valor busca que los medios de comunicación se adapten a los nuevos tiempos.

`HTMLMediaElement.defaultMuted` (en-US)

Es un `booleano` que refleja el `silenciado`. Atributo HTML, que indica si la salida de audio del elemento multimedia debe silenciarse de forma predeterminada.

`HTMLMediaElement.defaultPlaybackRate` (en-US)

Es un doble que indica la velocidad de reproducción predeterminada del material.

`HTMLMediaElement.disableRemotePlayback` (en-US)

Es un `Booleano` que establece o devuelve el estado de reproducción remota, indicando si el elemento multimedia puede tener una interfaz de reproducción remota.

`HTMLMediaElement.duration` (en-US) Read only 

Devuelve un doble indicando la longitud del material en segundos, o 0 si no hay datos de material disponibles.

`HTMLMediaElement.ended` (en-US) Read only 

Devuelve un `Booleano` que indica si el elemento multimedia ha terminado de reproducirse.

`HTMLMediaElement.error` (en-US) Read only 

Returns a `MediaError` (en-US) object for the most recent error, or `null` if there has not been an error.

`HTMLMediaElement.loop` (en-US)

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

`HTMLMediaElement.mediaGroup` (en-US)

Is a `DOMString` that reflects the `mediagroup` HTML attribute, which indicates the name of the group of elements it belongs to. A group of media elements shares a common `MediaController`.

`HTMLMediaElement.mediaKeys` (en-US) Read only  
Experimental

Returns a `MediaKeys` (en-US) object or `null`. MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback.

`HTMLMediaElement.mozAudioCaptured` Read only  
Non-standard

Returns a `Boolean`. Related to audio stream capture.

`HTMLMediaElement.mozFragmentEnd` 
Non-standard

Is a `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.

`HTMLMediaElement.mozFrameBufferLength` 
Non-standard

Obsoleto

Is a `unsigned long` that indicates the number of samples that will be returned in the framebuffer of each `MozAudioAvailable` event. This number is a total for all channels, and by default is set to be the number of channels \* 1024 (e.g., 2 channels \* 1024 samples = 2048 total).

The `mozFrameBufferLength` property can be set to a new value for lower latency, larger amounts of data, etc. The size given *must* be a number between 512 and 16384. Using any other size results in an exception being thrown. The best time to set a new length is after the loadedmetadata (en-US) event fires, when the audio info is known, but before the audio has started or `MozAudioAvailable` events have begun firing.

`HTMLMediaElement.mozSampleRate` Read only  
Non-standard

Obsoleto

Returns a `double` representing the number of samples per second that will be played. For example, 44100 samples per second is the sample rate used by CD audio.

`HTMLMediaElement.muted` (en-US)

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

`HTMLMediaElement.networkState` (en-US) Read only 

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

`HTMLMediaElement.paused` Read only 

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

`HTMLMediaElement.playbackRate` (en-US)

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

`HTMLMediaElement.played` Read only 

Returns a `TimeRanges` (en-US) object that contains the ranges of the media source that the browser has played, if any.

`HTMLMediaElement.preload`

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

`HTMLMediaElement.preservesPitch` (en-US) 
Non-standard

Is a `Boolean` that determines if the pitch of the sound will be preserved. If set to `false`, the pitch will adjust to the speed of the audio. This is implemented with prefixes in Firefox (`mozPreservesPitch`) and WebKit (`webkitPreservesPitch`).

`HTMLMediaElement.readyState` (en-US) Read only 

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

`HTMLMediaElement.seekable` (en-US) Read only 

Returns a `TimeRanges` (en-US) object that contains the time ranges that the user is able to seek to, if any.

`HTMLMediaElement.seeking` Read only 

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

`HTMLMediaElement.sinkId` (en-US) Read only  
Experimental

Returns a `DOMString` that is the unique ID of the audio device delivering output, or an empty string if it is using the user agent default. This ID should be one of the `MediaDeviceInfo.deviceid` values returned from `MediaDevices.enumerateDevices()` (en-US), `id-multimedia`, or `id-communications`.

`HTMLMediaElement.src` (en-US)

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

`HTMLMediaElement.srcObject` (en-US)

Is a `MediaStream` (en-US) representing the media to play or that has played in the current `HTMLMediaElement`, or `null` if not assigned.

`HTMLMediaElement.textTracks` (en-US) Read only 

Returns the list of `TextTrack` objects contained in the element.

`HTMLMediaElement.videoTracks` (en-US) Read only 

Returns the list of `VideoTrack` (en-US) objects contained in the element.

**Nota:** Gecko sólo soporta la reproducción de una sola pista, y el análisis de los metadatos de las pistas sólo está disponible para los medios con el formato de contenedor Ogg.

`HTMLMediaElement.volume` (en-US)

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

### Event handlers

`HTMLMediaElement.onencrypted` (en-US)

Sets the `EventHandler` (en-US) called when the media is encrypted.

`HTMLMediaElement.onwaitingforkey` (en-US)

Sets the `EventHandler` (en-US) called when playback is blocked while waiting for an encryption key.

Obsolete attributes
-------------------

These attributes are obsolete and should not be used, even if a browser still supports them.

`HTMLMediaElement.initialTime` Read only  
Non-standard

Obsoleto

Returns a `double` that indicates the initial playback position in seconds.

`HTMLMediaElement.mozChannels` Read only  
Non-standard

Obsoleto

Returns a `double` representing the number of channels in the audio resource (e.g., `2` for stereo).

### Obsolete event handlers

`HTMLMediaElement.onmozinterruptbegin` 
Non-standard

Obsoleto

Sets the `event handler` called when the media element is interrupted because of the Audio Channel manager. This was Firefox-specific, having been implemented for Firefox OS, and was removed in Firefox 55.

`HTMLMediaElement.onmozinterruptend` 
Non-standard

Obsoleto

Sets the `EventHandler` (en-US) called when the interruption is concluded. This was Firefox-specific, having been implemented for Firefox OS, and was removed in Firefox 55.

Methods
-------

*This interface also inherits methods from its ancestors `HTMLElement`, `Element`, `Node`, and `EventTarget`.*

`HTMLMediaElement.addTextTrack()`

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

`HTMLMediaElement.captureStream()` (en-US) 
Experimental

Returns `MediaStream` (en-US), captures a stream of the media content.

`HTMLMediaElement.canPlayType()` (en-US)

Determines whether the specified media type can be played back.

`HTMLMediaElement.fastSeek()` (en-US)

Directly seeks to the given time.

`HTMLMediaElement.load()` (en-US)

Resets the media to the beginning and selects the best available source from the sources provided using the `src` attribute or the `<source>` element.

`HTMLMediaElement.mozCaptureStream()` 
Non-standard

[enter description]

`HTMLMediaElement.mozCaptureStreamUntilEnded()` 
Non-standard

[enter description]

`HTMLMediaElement.mozGetMetadata()` 
Non-standard

Returns `Object`, which contains properties that represent metadata from the playing media resource as `{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 (en-US) event fires.

`HTMLMediaElement.pause()`

Pauses the media playback.

`HTMLMediaElement.play()`

Begins playback of the media.

`HTMLMediaElement.seekToNextFrame()` (en-US) 
Non-standard

Experimental

Seeks to the next frame in the media. This non-standard, experimental method makes it possible to manually drive reading and rendering of media at a custom speed, or to move through the media frame-by-frame to perform filtering or other operations.

`HTMLMediaElement.setMediaKeys()` (en-US) 
Experimental

Returns `Promise`. Sets the `MediaKeys` (en-US) keys to use when decrypting media during playback.

`HTMLMediaElement.setSinkId()` (en-US) 
Experimental

Sets the ID of the audio device to use for output and returns a `Promise`. This only works when the application is authorized to use the specified device.

Obsolete methods
----------------

These methods are obsolete and should not be used, even if a browser still supports them.

`HTMLMediaElement.mozLoadFrom()` 
Non-standard

Obsoleto

This method, available only in Mozilla's implementation, loads data from another media element. This works similarly to `load()` except that instead of running the normal resource selection algorithm, the source is simply set to the `other` element's `currentSrc`. This is optimized so this element gets access to all of the `other` element's cached and buffered data; in fact, the two elements share downloaded data, so data downloaded by either element is available to both.

Especificaciones
----------------

| Specification |
| --- |
| HTML Standard # htmlmediaelement |

Compatibilidad con navegadores
------------------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* References
    + `<video>` and `<audio>` HTML elements.
    + `HTMLVideoElement` and `HTMLAudioElement` interfaces, derived from `HTMLMediaElement`.
* Articles
    + Using HTML5 audio and video (en-US)
    + Media formats supported by the audio and video elements (en-US)
    + Web Audio API