Android does not play html5 sound at intervals

I am trying to play audio using the HTML5 Audio tag on my phone. I downloaded the sound, but when I run the .play () command, nothing happens. I made visible the default controls to check by clicking this play button and that it works and the sound is playing. I also tried to play the sound by executing javascript from the address bar, and this also works.

The code I use for playback looks something like this:

setInterval(function(){
    if(blahblah){
        document.getElementById("player").play();
    }
},500);

To make sure that he even tries to play the sound, I put a warning after it, for example:

setInterval(function(){
    if(blahblah){
        document.getElementById("player").play();
        alert("Played!");
    }
},500);

I saw a warning, but the sound did not play.

Thanks for any help :)

+5
source share
1 answer

, . , ( ), setInterval, , .

, , , , setInterval. - - , , . :

document.getElementById("player").play();
document.getElementById("player").pause();

setInterval(function(){
    document.getElementById("player").play();
}, 500);

, , . , .

+1

All Articles