Computer >> Computer tutorials >  >> Programming >> Javascript

Can I play the same sound more than once at the same time with HTML5?


To play the sound more than once at the same time, you need to clone the <audio> element. This works for Google Chrome −

var sound = document.getElementById("incomingMessageSound")
var sound2 = sound.cloneNode();
sound.play()
sound2.play()

The cloneNode is useful to return a duplicate of the node and helps in running the sound again.