代码示例:(标识:eg_html5_av_met_addtexttrack)
<!DOCTYPE html> 
<html> 
<body> 

<button onclick="addNewTextTrack()" type="button">添加一个新的文本轨道</button>
<br />
<br />
<video id="video1" controls="controls">
  <source src="/static/demo/video/mov_bbb.mp4" type="video/mp4">
  <source src="/static/demo/video/mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<script>
myVid=document.getElementById("video1");
function addNewTextTrack()
  { 
  text1=myVid.addTextTrack("caption");
  text1.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true));
  } 
</script> 

</body> 
</html>
运行结果: