Audio audioTracksProperty

Audio 对象参考手册Audio Object

Example

Get the number of available audio tracks:

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

Try it Yourself »

Definition and Usage

The audioTracks property returns an AudioTrackList object.

Returns an AudioTrackList object representing the available audio tracks.

Each audio track represents an AudioTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers do not support the audioTracks property.


Syntax

audioObject.audioTracks

Return Value

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

AudioTrackList object:

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

Note:(index) 0 represents the first available AudioTrack object.

AudioTrack object Represents an audio track.

AudioTrack object properties:

  • id - gets the id of the audio track
  • kind - gets the type of the 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 track is active (true|false)


Audio 对象参考手册Audio object Other extensions