Audio audioTracks attribute

Definition and usage

audioTracks The property returns an AudioTrackList object.

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

Each available audio track is represented by an AudioTrack object.

Example

Get the number of available audio tracks:

var x = document.getElementById("myAudio").audioTracks.length;

Try it yourself

Syntax

audioObject.audioTracks

Return value

Type Description
AudioTrackList object

Represents the available audio tracks of the audio.

AudioTrackList object:

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

Note:The first available AudioTrack object is at index 0

AudioTrack object

Represents the audio track.

AudioTrack object properties:

  • id - Get the id of the audio track
  • kind - Get the type of the audio track
  • label - Get the label of the audio track
  • language - Get the language of the track
  • enabled - Get or set whether the track is active (true|false)

The kind attribute can be of the following types:

  • "alternative"
  • "description"
  • "main"
  • "translation"
  • "commentary"
  • "" (Empty String)

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Not Supported Not Supported Not Supported Not Supported Not Supported