How to play sound on click without waiting for the previous sound to finish playing? Spamming the button = Spamming the sound file?

I got a sound on click, on a button. But I can’t rapidly spam the button to hear that sound over and over again, instead I have to wait until the sound is over to play it again. How can I let the sound, when playing, get interrupted by a new click, playing the sound from the start?

<script>
  function play(){
       var audio = document.getElementById("audio");
       audio.play();
                 }           
   </script>

<button onclick="play()">
     <audio id="audio" src="bell.ogg" ></audio> </button>
</body>

Hi there StupidQuestionsNeed,

and a warm welcome to these forums. :winky:

Check out this attachment,

gong.zip (571.5 KB)

… to see hear a possible method :wonky:

coothead

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.