HTML5 轨道不工作
HTML5 track not working
我的示例视频中未加载 Srt 文件。我已附上 html 和 srt 文件。mp4 是示例 video.Am 我哪里出错了?
<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
您的 "kind" 属性中缺少 "s"。
应该是这样的:
<track src="sample.srt" kind="subtitles" srclang="en" label="English"/>
此外,您应该尝试将字幕文件从 .srt 更改为 .vtt,因为浏览器更喜欢它:)
我的示例视频中未加载 Srt 文件。我已附上 html 和 srt 文件。mp4 是示例 video.Am 我哪里出错了?
<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
您的 "kind" 属性中缺少 "s"。 应该是这样的:
<track src="sample.srt" kind="subtitles" srclang="en" label="English"/>
此外,您应该尝试将字幕文件从 .srt 更改为 .vtt,因为浏览器更喜欢它:)