这就是我所拥有的......
<video id="video" controls="controls" preload="metadata" poster="/video/promotional/transparent.png">
<source src="/video/promotional/promotional.mp4" type="video/mp4" />
<source src="/video/promotional/promotional.webm" type="video/webm" />
<source src="/video/promotional/promotional.ogv" type="video/ogg" />
<track src="/video/promotional/promotional.vtt" label="English Captions" kind="subtitles" srclang="en-us" />
</video>
<script type="text/javascript">
$(document).ready(function() {
var video = document.querySelector('#video');
var.track = video.textTracks[0];
track.mode = 'hidden';
});
</script>
我希望这会默认关闭隐藏式字幕,但似乎并非如此。有什么想法吗?
答案 0 :(得分:2)
你的答案非常接近(我认为var.track =
是一个拼写错误 - 修复可以在OSX上使用Chrome和Safari,而在PC上使用IE浏览器)。为了重复使用,我喜欢将textTracks分成一个变量,但这是个人偏好:
<script type="text/javascript">
$(document).ready(function() {
var video = document.querySelector('#video'); // get the video element
var tracks = video.textTracks; // one for each track element
var track = tracks[0]; // corresponds to the first track element
track.mode = 'hidden';
});