动态添加视频字幕轨道会使它们的顺序错误
当我尝试将视频文本轨道添加到 videoJs 播放器时,它以错误的顺序添加它们,其中新轨道出现在上一个轨道之上。
我创建了一个 jsFiddle 来展示这一点,任何人都可以帮助解决我如何解决这个问题吗?
https://jsfiddle.net/ts9qogdh/3/
<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
data-setup='{ }' muted>
<source src="http://vjs.zencdn.net/v/oceans.mp4" type='video/mp4'>
</video>
var currPlayer = videojs("my_video_1")
currPlayer.play()
currPlayer.addTextTrack("captions", 'english', 'en');
window.setInterval(() => {
let currentTime = currPlayer.currentTime();
const activeCue = new VTTCue(currentTime, currentTime + 2, currentTime + 2)
var tracks = currPlayer.textTracks();
let existing = tracks.tracks_.find(x => x.kind === 'captions' && x.language === 'en');
existing.mode = 'showing';
existing.addCue(activeCue);
}, 1000)
When I try and add video text tracks to videoJs player, it adds them in the wrong order where the new track appears above the previous track.
I have created a jsFiddle to show this, can anyone help solve how I fix this?
https://jsfiddle.net/ts9qogdh/3/
<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
data-setup='{ }' muted>
<source src="http://vjs.zencdn.net/v/oceans.mp4" type='video/mp4'>
</video>
var currPlayer = videojs("my_video_1")
currPlayer.play()
currPlayer.addTextTrack("captions", 'english', 'en');
window.setInterval(() => {
let currentTime = currPlayer.currentTime();
const activeCue = new VTTCue(currentTime, currentTime + 2, currentTime + 2)
var tracks = currPlayer.textTracks();
let existing = tracks.tracks_.find(x => x.kind === 'captions' && x.language === 'en');
existing.mode = 'showing';
existing.addCue(activeCue);
}, 1000)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个 CSS 应该可以工作。不过,在 IE11 中,标题有点间隔……
This CSS should work. Although, in IE11 the captions are a bit spaced-out...