Latest web development tutorials

HTML Audio / Video DOM addTextTrack () method

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

Examples

Adding a new text to the video track:

text1=myVid.addTextTrack("caption");
text1.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true));

try it"

Definition and Usage

addTextTrack () method creates and returns a new TextTrack object.

TextTrack new object is added to the video / audio (audio / video) elements in text track list.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers do not support addTextTrack () method.


grammar

audio|video .addTextTrack( kind , label , language )

parameter

描述
kind 规定文本轨道的类型。

可能的值:

  • "subtitles"
  • "caption"
  • "descriptions"
  • "chapters"
  • "metadata"
label 字符串值,为文本轨道规定标签。用于为用户对文本轨道进行标识。
language 双字母语言代码,规定文本轨道的语言。
如需查看所有可用的语言代码,请参阅我们的 语言代码参考手册

return value

类型 描述
TextTrack 对象 表示新的文本轨道。


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