play(state,event){ const playerBar=document.getElementById("playerBar"); const eve=event.target; let duraTime=playerBar.duration; let duraMinute=Math.floor(duraTime/60)+":"+(duraTime%60/100).toFixed(2).slice(-2); let currentTime=playerBar.currentTime; let currentMinute=Math.floor(currentTime/60)+":"+(currentTime%60/100).toFixed(2).slice(-2); let ctime; if(playerBar.paused){ playerBar.play(); eve.innerHTML="pause"; state.audio.duration=duraMinute; state.audio.currentTime=currentMinute; ctime=setInterval( function(){ duraTime--; currentTime++; duraMinute=Math.floor(duraTime/60)+":"+(duraTime%60/100).toFixed(2).slice(-2); currentMinute=Math.floor(currentTime/60)+":"+(currentTime%60/100).toFixed(2).slice(-2); state.audio.duration=duraMinute; state.audio.currentTime=currentMinute; },1000 ) }else{ playerBar.pause(); eve.innerHTML="play_arrow"; clearInterval(ctime); } }
play()绑定的是一个播放器的开关,,点击一次时间会动,用的是定时器setInterval,再次点击清除计时器,时间暂停,用了clearInterval,但是目前clearInterval失效,不知道什么原因,拜托大神帮看看!!
橋本奈奈未
相关分类