I have this function to play music using the web audio API:
function playMusic(){ if(countPre<count ){ audio0.play(); audio0.src = '0.mp3'; audio0.controls = true; audio0.autoplay = true; audio0.loop = true; source = context.createBufferSource(); source.connect(analyser); analyser.connect(context.destination); } else{audio0.pause();} }
However, count and countPre are generated in a loop that starts 10 times per second.
I need to put the playMusic function inside in this loop to update the values.
And here is the problem:
I call playMusic 10 times per second! Each time the music resumes .
I do not want it to resume, I want it to play continuously until the playback condition matches.
So is there any solution?
kikkpunk
source share