<html>
  <head>
	<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>WebCat</title>
    <style>
      *{
       margin:0;
        padding:0;
       }
      img{
        width:100vw;
       }
     #inp,#oop{
       text-align:center;
       font-size:10vw;
       }
    </style>
    <script src="js/jquery.min.js"></script>
  </head>
  <body>	
	<img src="img/1.jpg" id="img"/>
    <div id="inp">播放视频</div>
    <div id="oop"></div>
 <script>
 let kpo;
 let autoi = 0;
 const audio = new Audio('mp3/0.mp3');
function bofang(fps) {
  img.src = "img/" + fps + ".jpg";
  $("#inp").text(fps);
  console.log(fps);
}
inp.onclick=function(){
  if(autoi == 0){ // 添加判断,如果当前正在播放,则不执行播放代码
    $("#oop").text("暂停播放");
    autoi = 1;
    let tyt = 1;
    audio.play();
    setInterval(
    function(){
      if(tyt < 1196 && tyt > 0){
        if(autoi == 1){
         bofang(tyt);
         tyt++;
        }else{
         kpo = tyt;
         alert(tyt);
         tyt = -1;
         audio.pause();
        }
      }else{
        if(autoi == 1){
         tyt = 1;
         audio.currentTime = 0;
         audio.play();
        }else{
<pre><code>     tyt = -1;
     audio.pause();
    }
  }
 ;},10);
</code></pre>
<p>}
}</p>
<p>/*
function jixvbf(tyt){
autoi = 1;
audio.play();
setInterval(
function(){if(tyt &lt; 1196 &amp;&amp; tyt &gt; 0){
if(autoi == 1){
bofang(tyt);
tyt++;
}else{
kpo = tyt;
tyt = -1;
audio.pause();
}
}else{
if(autoi == 1){
tyt = 1;
audio.currentTime = 0;
audio.play();
}else{
kpo = tyt;
tyt = -1;
audio.pause();
}
}
;},10);
}
*/</p>
<p>oop.onclick=function (){
if(autoi == 1){
autoi = 0;
$(&quot;#oop&quot;).text(&quot;继续播放&quot;);
}else{
alert(kpo);
autoi = 1;
$(&quot;#oop&quot;).text(&quot;暂停播放&quot;);
}
}</p>
</script>
  </body>
</html>
WebCat - 播放视频

原文地址: https://www.cveoy.top/t/topic/n6vq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录