Answers for "play audio on click"

3

javascript play sound onclick

var audio = new Audio("soundfile.wav");

document.onclick = function() {
  audio.play();
}
Posted by: Guest on June-06-2020
0

play audio button

<script>
var audio = new Audio("http://music.ogg" ) ;

audio.oncanplaythrough = function(){
audio.play();
}

audio.loop = true;

audio.onended = function(){
audio.play();
}

</script>

<input type="image" src="http://button.png" onclick="audio.play()">
Posted by: Guest on February-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language