title: JavaScript play audio one after another HTML5
body: <p>I have a problem with playing audio from a dynamically created javascript audio object one after another. The Audio comes from Google over an array of strings.  </p>
  
  <pre><code>for (i = 0; i &lt; Txt_array.length; i++) {
  audio.src ='http://translate.google.com/translate_tts?&amp;tl=en&amp;q='+Txt_array[i];
  audio.play();};
  </code></pre>
  
  <p>I would like to do this by an event listener, or is there any other way? It is not just about Google, so I would like to ask you for a general solution, not a ready made google speech script.</p>
  
  <p>Could you help me? How can I play the audio one after another?</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>audio.src='http://translate.google.com/translate_tts?&amp;tl=en&amp;q=' + Txt_array[0];
  audio.play();
  
  audio.addEventListener('ended', function(){
  for (i = 1; i &lt; Txt_array.length; i++) {
  audio.src ='http://translate.google.com/translate_tts?&amp;tl=en&amp;q='+Txt_array[i];
  audio.play();};
  }, false);
  </code></pre>
  
  <p>I added the Eventlistener, I guess it should work like this, but I still hae a problem that the Eentlistener does not fire if this is the first file played, right?</p>
  
  <p>I would be happy for further support.</p>
  
  <p>Thank you in advance.</p>