将ended
函数放入setInterval
function video_close_timer() {
var videoTimer = 1000; // Check if the video ended every second
var timerId = undefined; // The ID of the Interval
timerId = setInterval(function() {
if (video_closed_scrollPlay()) {
clearInterval(timerId);
timerId = undefined;
};
}, videoTimer);
};
function video_has_closed() {
if (vid.currentTime >= vid.duration) {
window.scrollTo(0, 1000);
return true;
};
return false;
};
function video_closed_scrollPlay() {
var result = video_has_closed();
scrollPlay();
return result;
};
function ended() {
return video_closed_scrollPlay();
};
video_close_timer
视频开始时调用该函数。