mhmd mhmd - 3 months ago 24
jQuery Question

Autoplay sound mp3 each one minute

how can using php play a sound each 1 or 2 min

when a user enter in the page the first sound play

after 1 min another sound will be played and the first will be stopped of
course all that will be auto play

html5 code:

<audio controls autoplay>
<source src="horse.mp3" type="audio/mpeg">
</audio>

Answer

Simply you can merge both sound with your timing and implemented just like this:

<audio controls="controls" onloadeddata="audioSoundFunction()">
    <source src="horse.mp3" type="audio/mp3" />
</audio>

Javascript:

function audioSoundFunction() {
  var audioSound = this; 
  setTimeout(function() { 
    audioSound.play(); 
  }, 10000)
}
Comments