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

JavascriptWeb DevelopmentFront End Scripts

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.

raja
Published on 06-Apr-2018 13:37:33
Advertisements