Latest web development tutorials

HTML Audio / Video DOM audioTracks property

HTML audio / video Tag Reference HTML Audio / Video DOM Reference

Examples

Get the number of available audio tracks:

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

try it"

Definition and Usage

audioTracks property returns AudioTrackList object.

AudioTrackList object represents the audio / video available audio tracks.

Each of the available audio tracks are represented by a AudioTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers do not support audioTracks property.


grammar

audio|video .audioTracks

return value

类型 描述
AudioTrackList 对象 表示音频/视频的可用音频轨道。

AudioTrackList 对象:

  • audioTracks.length - 获得可用音频轨道的数量
  • audioTracks.getTrackById( id ) - 通过 id 来获得 AudioTrack 对象
  • audioTracks[ index ] - 通过 index 来获得 AudioTrack 对象

注释:第一个可用的 AudioTrack 对象的下标是 0。

AudioTrack 对象 表示音频轨道。

AudioTrack 对象的属性:

  • id - 获得音频轨道的 id
  • kind - 获得音频轨道的类型(可以是 "alternative"、"description"、"main"、"translation"、"commentary" 或者 ""(空字符串))
  • label - 获得音频轨道的标签
  • language - 获得音频轨道的语言
  • enabled - 获得或设置音频轨道是否是活动的(true|false)


HTML audio / video Tag Reference HTML Audio / Video DOM Reference