HTML Audio/Video DOMaudioTracksProperty

HTML Audio/Video DOM Reference Manual

Example

Get the number of available audio tracks:

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

Try it Yourself »

Definition and Usage

The audioTracks property returns an AudioTrackList object.

The AudioTrackList object represents the available audio tracks of audio/video.

Each available audio track is represented by an AudioTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers do not support the audioTracks property.


Syntax

audio|video.audioTracks

Return Value

Type Description
AudioTrackList object Represents the available audio tracks of audio/video.

AudioTrackList object:

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

Note:Of the first available AudioTrack objectIndexis 0.

AudioTrack object Indicates the audio track.

Properties of AudioTrack objects:

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


HTML Audio/Video DOM Reference Manualother extensions