视频页面代码的背景如下:
<video id="kon">
<source data-src="comp/vid/gyu.webm?>" media="(min-width: 640px)" src="<?=SITE_MEDIA?>video/gyu.webm?>">
</video>
我希望在完成视频后保持视频10秒钟 再次开始。它没有停顿我怎么能让它暂停10秒并开始它
答案 0 :(得分:0)
$(function() {
var vid = document.getElementById("video");
vid.playbackRate = 0.4;
vid.onended = function() {
setTimeout(function(){
vid.play(); //will play after 10 seconds when video is ended
}, 10000);
};
vid.play(); // will play on load.
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<video id="video" width="320" height="240">
<source src="https://www.w3schools.com/html/movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
&#13;
您可以在onended
事件中使用setTimeout在10秒后播放视频:
var vid = document.getElementById("kon");
vid.playbackRate = 0.4;
vid.onended = function() {
setTimeout(function(){
vid.play(); //will play after 10 seconds when video is ended
}, 10000);
};
vid.play(); // will play on load.