HTMLMediaElement: audioTracks property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The read-onlyaudioTracksproperty onHTMLMediaElement objects returnsanAudioTrackList object listing all of theAudioTrackobjects representing the media element's audio tracks.
The media element may beeither an<audio> element or a<video> element.
The returned list islive; that is, as tracks are added to and removed fromthe media element, the list's contents change dynamically. Once you have a reference tothe list, you can monitor it for changes to detect when new audio tracks are added orexisting ones removed. SeeAudioTrackList eventsto learn more about watching for changes to a media element's track list.
In this article
Value
AnAudioTrackList object representing the list of audio tracks includedin the media element. The list of tracks can be accessed using array notation, or usingthe object'sgetTrackById() method.
Each track is represented by anAudioTrack object which providesinformation about the track.
Examples
In this example, all of the audio tracks on a given element are muted.
HTML
The HTML establishes the element itself.
<video src="somevideo.mp4"></video>JavaScript
The JavaScript code handles muting the video element's audio tracks.
const video = document.getElementById("video");for (const track of video.audioTracks) { track.enabled = false;}Specifications
| Specification |
|---|
| HTML> # dom-media-audiotracks-dev> |
Browser compatibility
See also
HTMLMediaElement: Interface used to define theHTMLMediaElement.audioTracksproperty<audio>,<video>AudioTrack,AudioTrackList