我的示例视频中没有加载Srt文件。我已经附加了html和srt文件.mp4是一个示例视频。我在哪里错了?
<body>
<video id="myVideo" >
<source src="rock.mp4"/>
<track src="sample.srt" kind="subtitle" srclang="en" label="English"/>
</video>
<button onclick="play()">play</button>
<button onclick="pause()">pause</button>
<button onclick="smallwidth()">small width</button>
<button onclick="bigwidth()">big width</button>
</body>
<script>
function play(){
myVideo.play();
}
function pause(){
myVideo.pause();
}
function smallwidth(){
myVideo.width=200;
}
function bigwidth(){
myVideo.width=300;
}
</script>
</html>
sample.srt
1
00:00:01.000 --> 00:01:05.000
This is rockmp4
2
00:01:05.000 --> 00:05:10.000
file was specified using the 'track' element
答案 0 :(得分:1)
你错过了一个&#34; s&#34;在你的&#34; kind&#34;属性。 它应该是这样的:
<track src="sample.srt" kind="subtitles" srclang="en" label="English"/>
此外,您应该尝试从.srt更改您的替代文件到.vtt,因为它更受浏览器的欢迎:)