Tag Archives: jquery play two sounds at once

JavaScript Play Two Sounds at Once

Anyone following my blog may know I have undertaken 3D web development. This includes games and other 3D content for websites. Sound is particularly important to video game development. When it comes to building games with JavaScript, we have to know how to handle multiple sound files at once.  I actually tried a lot of tricks before I found this simple jQuery solution that works:

<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script>
$(document).ready(function() {
console.log( "Ian says the document is ready!" );
var audio = new Audio('sounds/beat.mp3');
audio.play();
var audio2 = new Audio('sounds/song.mp3');
audio2.play();
});//end doc ready fun
</script>