HTML Audio/Video DOM audioTracks attribute

Example

Get the number of available tracks:

myVid=document.getElementById("video1");
alert(myVid.audioTracks.length);

Try it yourself

Definition and usage

The audioTracks attribute returns an AudioTrackList object.

The AudioTrackList object represents the available audio and video tracks.

Each available track is represented by an AudioTrack object.

Browser support

Any mainstream browser does not support the audioTracks attribute.

Syntax

audio|video.audioTracks

Return value

Type Description
AudioTrackList object

Represents the available audio tracks for audio and video.

AudioTrackList Object:

  • audioTracks.length - or the number of available tracks
  • audioTracks.getTrackById(id) - Get the AudioTrack object by id
  • audioTracks[index] - Get the AudioTrack object by index

Note:The index of the first available AudioTrack object is 0.

AudioTrack Object

Represents the track.

Properties of AudioTrack Object:

  • id - Get the id of the track
  • kind - Get the type of the track (can be "alternative", "description", "main", "translation", "commentary", or "" (empty string))
  • label - Get the label of the track
  • language - Get the language of the track
  • enabled - Get or set whether the track is active (true|false)