Latest web development tutorials

HTML Audio / Video DOM textTracks property

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

Examples

Obtaining the number of tracks available text:

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

try it"

Definition and Usage

textTracks property returns TextTrackList object.

TextTrackList object represents the audio / video available text track.

Each track is made available text TextTrack object represents.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Opera, Chrome and Safari 6 support textTracks property.

Note: 9 and earlier versions of Internet Explorer does not support textTracks property.


grammar

audio|video .textTracks

return value

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

TextioTrackList 对象:

  • length - 获得音频/视频中可用的文本轨道的数量
  • [ index ] - 根据下标 index 来获得 TextTrack 对象

注释:第一个可用文本轨道的下标 index 是 0。

TextTrack 对象 表示一个文本轨道。

TextTrack 对象的属性:

  • kind - 获得文本轨道的类型(可以是 "subtitles"、"caption"、"descriptions"、"chapters" 或者 "metadata")
  • label - 获得文本轨道的标签
  • language - 获得文本轨道的语言
  • mode - 获得或设置该轨道是否是活动的("disabled"|"hidden"|"showing")
  • cues - 获得 TextTrackCueList 对象的 cues 列表
  • activeCues - 获得 TextTrackCueList 对象形式的当前活动文本轨道 cues
  • addCue( cue ) - 向 cues 列表添加一个 cue
  • removeCue( cue ) - 从 cues 列表删除一个 cue


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