How do I play multiple sound files at once in JS?
if i use
audio.play(); more than once, it cuts the other audio out. is there a way to fix it?
The best, and easiest, way I know of is to use hidden
audio elements in the DOM (set their
display CSS property to
none). Put an id on them (such as
audio2, etc.), and then you can just call them both at the same time to play them (or as many as you'd like):
And they will play at the same time. You can use the same controls with the audio DOM elements that you can with the JS loaded audio objects, so that you can dynamically pause them, as well! =]