虽然我已经能够使用普通 HTML5 播放器监听“timeupdate”事件,但我似乎无法让它与 video.js 一起使用。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<link href="video-js.css" rel="stylesheet">
<script src="video.js"></script>
<script src="jquery.min.js"></script>
</head>
<body>
<video id="testvid" class="video-js vjs-default-skin" controls width="640" height="480" data-setup='{}'>
<source src="testvideo.mp4" type="video/mp4">
</video>
</body>
</html>
<script>
videojs('testvid').ready(function(){
var myPlayer = this;
$(myPlayer).bind('timeupdate', function(){
console.log('the time was updated to: ' + this.currentTime);
});
});
</script>
我是否误解了 video.js 的基本运作方式?
实际上,您可以在ready()的回调中注册事件,这是更好的解决方案,因为在上一篇中事件的注册仍然可以在ready()之后完成。使用以下代码片段:
videojs('example_video_1').ready(function () {
this.on('timeupdate', function () {
console.log(this.currentTime());
})
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)