AudioTrack

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The AudioTrack interface represents a single audio track from one of the HTML media elements, <audio> or <video>.

The most common use for accessing an AudioTrack object is to toggle its enabled property in order to mute and unmute the track.

Instance properties

enabled

A Boolean value which controls whether or not the audio track's sound is enabled. Setting this value to false mutes the track's audio.

id Read only

A string which uniquely identifies the track within the media. This ID can be used to locate a specific track within an audio track list by calling AudioTrackList.getTrackById(). The ID can also be used as the fragment part of the URL if the media supports seeking by media fragment per the Media Fragments URI specification.

kind Read only

A string specifying the category into which the track falls. For example, the main audio track would have a kind of "main".

label Read only

A string providing a human-readable label for the track. For example, an audio commentary track for a movie might have a label of "Commentary with director Christopher Nolan and actors Leonardo DiCaprio and Elliot Page." This string is empty if no label is provided.

language Read only

A string specifying the audio track's primary language, or an empty string if unknown. The language is specified as a BCP 47 language tag, such as "en-US" or "pt-BR".

sourceBuffer Read only

The SourceBuffer that created the track. Returns null if the track was not created by a SourceBuffer or the SourceBuffer has been removed from the MediaSource.sourceBuffers attribute of its parent media source.

Usage notes

To get an AudioTrack for a given media element, use the element's audioTracks property, which returns an AudioTrackList object from which you can get the individual tracks contained in the media:

js
const el = document.querySelector("video");
const tracks = el.audioTracks;

You can then access the media's individual tracks using either array syntax or functions such as forEach().

This first example gets the first audio track on the media:

js
const firstTrack = tracks[0];

The next example scans through all of the media's audio tracks, enabling any that are in the user's preferred language (taken from a variable userLanguage) and disabling any others.

js
tracks.forEach((track) => {
  track.enabled = track.language === userLanguage;
});

The language is specified as a valid BCP 47 language tag, for example "en-US" for US English.

Example

See AudioTrack.label for an example that shows how to get an array of track kinds and labels for a specified media element, filtered by kind.

Specifications

Specification
HTML
# audiotrack

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
AudioTrack
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
enabled
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
id
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
kind
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
label
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
language
Chrome – No support
Chrome 37 (Release date: 2014-08-26)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 33 (Release date: 2014-10-14)
disabled
disabled From version 33 users must explicitly set the media.track.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 24 (Release date: 2014-09-02)
disabled
disabled From version 24 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 37 (Release date: 2014-09-03)
disabled
disabled From version 37 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
sourceBuffer
Chrome – No support
Chrome 51 (Release date: 2016-05-25)
disabled
disabled From version 51 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 12 – 18 (Release date: 2015-07-29)
unknown Support unknown
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox
footnote No support
Opera – No support
Opera 38 (Release date: 2016-06-08)
disabled
disabled From version 38 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Opera, visit opera://flags.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android 51 (Release date: 2016-06-08)
disabled
disabled From version 51 users must explicitly set the enable-experimental-web-platform-features preference to enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Partial support
Safari on iOS 13 (Release date: 2019-09-19)
footnote Partial support
footnote Exposed in Mobile Safari on iPad but not on iPhone.
footnote See bug 200147
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Partial support
WebView on iOS 13 (Release date: 2019-09-19)
footnote Partial support
footnote Exposed in Mobile Safari on iPad but not on iPhone.
footnote See bug 200147

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
User must explicitly enable this feature.
Has more compatibility info.