lundi 30 mars 2015

How can I layer the same sound file with Audio API?

I have a sound that is 2 seconds long. It is bound to the enter key. I want to be able to press the enter key multiple times per second enabling multiple layers of the same sound.


Currently I can initiate the sound, but the next one won't play until the first one is finished.


This is the code that I have that works but does not layer the sounds upon multiple keypresses:





var fart = new Audio('http://ift.tt/1ILkbXu');

$(document).keydown(function(e) {
if(e.keyCode == 13)
{
fart.play();
}
});



<script src="http://ift.tt/1oMJErh"></script>

Click here then press enter.



This looked like it might contain the answer, but I wasn't able to get any executable code that worked for me: Sound effects in JavaScript / HTML5


Aucun commentaire:

Enregistrer un commentaire