设置多个点击事件,快进到指定预设时间点停止

问题描述

尝试按 id 设置多个 clickevents,并根据点击的 id 视频将快进到它在视频背景中分配的预定点。我对 javascript 相当陌生,并且已经为此努力了好几天,试图以零运气解决这个问题。

// Play Pause function

var ppbutton = document.getElementById("contact");
ppbutton.addEventListener("dblclick",playPause);
myVideo = document.getElementById("myvid");
function playPause() {
if (myVideo.paused) {
 myVideo.play();
 // ppbutton.innerHTML = "On My Way";
 //   } else {
 //     myVideo.pause();
 // ppbutton.innerHTML = "About";  
}


//   Speed Function
var vid = document.getElementById("myvid");
vid.playbackRate = 8.0;

// Stop interval function

var $video = $(myvid);
var video = $video.get(0);

video.addEventListener("timeupdate",function () {
 var lastCheckedAt = $video.data("lastcheck") || 0;
 $video.data("lastcheck",this.currentTime);

 if (this.currentTime >= 5 && lastCheckedAt < 5) {
   console.log("5 seconds");
   this.pause();
   $("button").show();
 } else if (this.currentTime >= 10 && lastCheckedAt < 10) {
   console.log("10 seconds");
   this.pause();
   $("button").text("Part 3").show();
 } else if (this.currentTime >= 20 && lastCheckedAt < 20) {
   console.log("20 seconds");
   this.pause();
   $("button").text("Part 4").show();
 } else if (this.currentTime >= 32 && lastCheckedAt < 32) {
   console.log("32 seconds");
   this.pause();
   $("button").text("Part 5").show();
 }
});

$("button").click(function () { ```
 video.play();
 $("button").hide();
});
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)