我使用 jwplayer 来处理我网站上的视频,但很难弄清楚如何在视频的特定百分比上触发事件。
这是我当前的代码:
jwplayer("myElement").setup({
file: "video.mp4",
height: 600,
width: 600,
events: {
onComplete: function() {
alert("hi!");
}
}
});
仅在完成时触发事件。即使视频完成 80%,我也想开火。
有什么建议吗?
最佳答案
这是您在 DEMO 上的解决方案
问题是您无法仅获取视频的duration
current duration
jwplayer("myElement").setup({
file: "video.mp4",
height: 600,
width: 600,
});
如果你的视频长度是 5:00 那么 durationtofire
= 4;
var durationtofire = 4;
jwplayer("myElement").onTime(function(event) {
if (event.position > durationtofire) {
alert("we are on 80%");
}
});
关于javascript - jwplayer 在 80% 的视频上调用事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20056329/