Video audioTracksProperty

Video 对象参考手册Video Object

Examples

Get the number of available audio tracks:

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

Try it Yourself »

Definition and Usage

The audioTracks property returns an AudioTrackList object.

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

Each available audio track is represented by an AudioTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The audioTracks property is not supported by any mainstream browser.


Syntax

videoObject.audioTracks

Return Value

Type Description
AudioTrackList object

Represents the available audio tracks of the audio/video.

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:The index of the first available AudioTrack object is 0.

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 audio track is active (true|false)


Video 对象参考手册Video Object Other Extensions