<!DOCTYPE html>
<html>
<body>
<audio id="myAudio" controls>
<source src="/i/audio/song.mp3" type="audio/mpeg">
<source src="/i/audio/song.ogg" type="audio/ogg">
您的浏览器不支持 audio 元素。
</audio>
<p>单击该按钮可添加新的文本轨道。</p>
<button onclick="myFunction()">试一试</button>
<p><b>注释:</b>任何主流浏览器都不支持 addTextTrack 方法。</p>
<script>
var x = document.getElementById("myAudio");
function myFunction() {
var y = x.addTextTrack("caption");
y.addCue(new TextTrackCue("Test text", 01.000, 04.000,"","","",true));
}
</script>
</body>
</html>