setInterval循环问题
functionplayMyAudios(a,c){varb=a;varaudio=document.getElementById("myAudio1");audio.s...
function playMyAudios(a,c){
var b = a;
var audio = document.getElementById("myAudio1");
audio.src = b==1?"....":"....";
audio.addEventListener("canplaythrough",function(){
audio.play();
});
audio.addEventListener("ended",function(){
var j = b==1?14:44;
var timer = setInterval(function(){
both(j,c);
j--;
if(j < 0 && b == 1){
clearInterval(timer);
both(45,2);
playMyAudios(2,2);
}
if(j<0 && b == 2){
clearInterval(timer);
}
},1000);
});
}
会有好几个循环同时发生 不知道是什么情况 好纠结 展开
var b = a;
var audio = document.getElementById("myAudio1");
audio.src = b==1?"....":"....";
audio.addEventListener("canplaythrough",function(){
audio.play();
});
audio.addEventListener("ended",function(){
var j = b==1?14:44;
var timer = setInterval(function(){
both(j,c);
j--;
if(j < 0 && b == 1){
clearInterval(timer);
both(45,2);
playMyAudios(2,2);
}
if(j<0 && b == 2){
clearInterval(timer);
}
},1000);
});
}
会有好几个循环同时发生 不知道是什么情况 好纠结 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询