admin管理员组文章数量:1328030
I've been messing with video.js whilst learning javascript but can't seem to figure out how to make the video pause after a certain time has passed.
myPlayer.play(function(){
whereYouAt = myPlayer.currentTime();
if (whereYouAt == 10) {
myPlayer.pause();
}
})
That is my pause code.
I've been messing with video.js whilst learning javascript but can't seem to figure out how to make the video pause after a certain time has passed.
myPlayer.play(function(){
whereYouAt = myPlayer.currentTime();
if (whereYouAt == 10) {
myPlayer.pause();
}
})
That is my pause code.
Share Improve this question asked Feb 18, 2015 at 17:44 xiimossxiimoss 8053 gold badges13 silver badges21 bronze badges 2- I think you need to wrap that in a setInterval() in order to check the time more often – Jonas Grumann Commented Feb 18, 2015 at 17:45
- @xiimoss jsfiddle/EdjxN/17 – Miguel Commented Feb 18, 2015 at 17:59
1 Answer
Reset to default 7Check the currentTime
in the timeupdate
event callback:
var pausetime = 2; // stop at 2 seconds
var myPlayer = videojs('example_video_1');
myPlayer.on('timeupdate', function(e) {
if (myPlayer.currentTime() >= pausetime) {
myPlayer.pause();
}
});
myPlayer.play();
JSFiddle demo: http://jsfiddle/EdjxN/17/
本文标签: javascriptHow to pause a video after a certain time videojsStack Overflow
版权声明:本文标题:javascript - How to pause a video after a certain time? video.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742236922a2438247.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论