title: Play audio stream with javascript API
body: <p>I have a web-server that streams wav audio and I would like to play it in a web browser using the javascript audio API.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>function start() {
      var request = new XMLHttpRequest();
      request.open("GET", url, true);
      request.responseType = "arraybuffer"; // Read as binary data
  
      request.onload = function() {
          var data = request.response;
          playSound(data);
      };
  }
  </code></pre>
  
  <p>The problem here is that onload wont be called until the data is completely loaded which is not very convenient for streaming.</p>
  
  <p>So I looked for another event and found onProgress but the problem is that request.response returns null if the data is not completely loaded.</p>
  
  <p>Whats the correct way to play an audio stream with javascript ?</p>
  
  <p>Thank's for your help.</p>
  
  <p>Lukas</p>