title: Reproduce audio files one after another
body: <p>I'm using HTML5 audio tag to play audio files one after another, but my routine seems to crash Firefox. It only works when I add an alert().</p>
  
  <p>I have a routine in PHP which checks every 2 seconds if another application has sent new events to the server, if so, I write the name of the new event on the screen. Some of these events have audio files related to them (they can be different sounds), so when the event arrives the audio file has to be played.</p>
  
  <p>I have this routine:</p>
  
  <p>When the event arrives I call this function: playSound(sound_name);</p>
  
  <pre><code>    function playSound(sound_name){
          if (!current_sound){
              current_sound = true;
              $("#audio-player")[0].src = "../snd/"+sound_name;
              //$("#audio-player")[0].load();
              $("#audio-player")[0].play();
          }
          else {
              //alert(sound_name);
              playSound(sound_name);
          }
      }
  </code></pre>
  
  <p>The variable "current_sound" is set to false when the audio_player fires the "ended" event of the audio tag. I attatched a function to this event so everytime it's fired it sets the variable current_sound to false.</p>
  
  <p>The problem with all this code is that it only works with that alert inside the function playSound(). If I comment it Firefox crashes and starts saying the js script is taking too long to complete (one of theirs js scripts, not mine).</p>
  
  <p>I've searched a lot, but I've only found examples about how to reproduce a given list of files which is not useful in my case 'cause I don't know which files will be played beforehand.</p>
  
  <p>Any suggestions?</p>