HTML Audio/Video DOM audioTracks Property

❮ HTML Audio/Video DOM Reference

Example

var vid = document.getElementById("myVideo");
function myFunction() {
  alert(vid.audioTracks.length);
}

Meaning

The audioTracks property returns an AudioTrackList object representing available audio tracks.


Standard Syntax

audio|video.audioTracks



Browser Support




Status







Return Value

Type Description
AudioTrackList Object Reruns the available audio tracks for the audio/video. The first available AudioTrack object is index 0.

AudioTrackList Object:

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

AudioTrack Object Properties:

  • id - get the id of the audio track.
  • kind - get the type of the audio track (it can be: "alternative", "description", "main", "translation", "commentary", or "" (empty string)).
  • label - get the label of the audio track.
  • language - get the language of the audio track.
  • enabled - get or set if the track is active (true|false).
❮ HTML Audio/Video DOM Reference