HTMLMediaElement
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since julio de 2015.
* Some parts of this feature may have varying levels of support.
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-
Un
AudioTrackListque lista losAudioTrackobjetos contenidos en el elemento. HTMLMediaElement.autoplay-
Un
Booleanoque refleja elautoplay. 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.bufferedRead only-
Devuelve un objeto
TimeRangesque 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-
Es un objeto
MediaControllerque representa el controlador de medios asignado al elemento, o nulo si no se asigna ninguno. HTMLMediaElement.controls-
Es un
booleanoque refleja elcontroles[1]. Atributo HTML, que indica si deben visualizarse las posiciones de la interfase de usuario para controlar el recurso. HTMLMediaElement.controlsListRead only-
Devuelve un
DOMTokenListque 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-
Es un
Stringque indica la configuración CORS para este elemento multimedia. HTMLMediaElement.currentSrcRead only-
Devuelve un
Stringcon la URL absoluta del recurso multimedia elegido. HTMLMediaElement.currentTime-
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-
Es un
booleanoque refleja elsilenciado. Atributo HTML, que indica si la salida de audio del elemento multimedia debe silenciarse de forma predeterminada. HTMLMediaElement.defaultPlaybackRate-
Es un doble que indica la velocidad de reproducción predeterminada del material.
HTMLMediaElement.disableRemotePlayback-
Es un
Booleanoque establece o devuelve el estado de reproducción remota, indicando si el elemento multimedia puede tener una interfaz de reproducción remota. HTMLMediaElement.durationRead only-
Devuelve un doble indicando la longitud del material en segundos, o 0 si no hay datos de material disponibles.
HTMLMediaElement.endedRead only-
Devuelve un
Booleanoque indica si el elemento multimedia ha terminado de reproducirse. HTMLMediaElement.errorRead only-
Returns a
MediaErrorobject for the most recent error, ornullif there has not been an error. HTMLMediaElement.loop-
Is a
Booleanthat reflects theloopHTML attribute, which indicates whether the media element should start over when it reaches the end. HTMLMediaElement.mediaGroup-
Is a
Stringthat reflects themediagroupHTML attribute, which indicates the name of the group of elements it belongs to. A group of media elements shares a commonMediaController. HTMLMediaElement.mediaKeysRead only-
Returns a
MediaKeysobject ornull. MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback. HTMLMediaElement.mozAudioCapturedRead only-
Returns a
Boolean. Related to audio stream capture. HTMLMediaElement.mozFragmentEnd-
Is a
doublethat provides access to the fragment end time if the media element has a fragment URI forcurrentSrc, otherwise it is equal to the media duration. HTMLMediaElement.mozFrameBufferLength-
Is a
unsigned longthat indicates the number of samples that will be returned in the framebuffer of eachMozAudioAvailableevent. 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
mozFrameBufferLengthproperty 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 event fires, when the audio info is known, but before the audio has started orMozAudioAvailableevents have begun firing. HTMLMediaElement.mozSampleRateRead only-
Returns a
doublerepresenting 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-
Is a
Booleanthat determines whether audio is muted.trueif the audio is muted andfalseotherwise. HTMLMediaElement.networkStateRead only-
Returns a
unsigned short(enumeration) indicating the current state of fetching the media over the network. HTMLMediaElement.pausedRead only-
Returns a
Booleanthat indicates whether the media element is paused. HTMLMediaElement.playbackRate-
Is a
doublethat indicates the rate at which the media is being played back. HTMLMediaElement.playedRead only-
Returns a
TimeRangesobject that contains the ranges of the media source that the browser has played, if any. HTMLMediaElement.preload-
Is a
Stringthat reflects thepreloadHTML attribute, indicating what data should be preloaded, if any. Possible values are:none,metadata,auto. HTMLMediaElement.preservesPitch-
Is a
Booleanthat determines if the pitch of the sound will be preserved. If set tofalse, the pitch will adjust to the speed of the audio. This is implemented with prefixes in Firefox (mozPreservesPitch) and WebKit (webk