title: Play streaming audio in JavaScript
body: <p>I'm currently using <code>node-lame</code> to encode a raw PCM input stream, and I have the following code in Node.JS that successfully outputs binary MP3 chunks:</p>
  
  <pre><code>server.on('request', (req, res) =&gt; {
    encoded.pipe(res);
  });
  </code></pre>
  
  <p>I try to request this code inside of my front-end interface with code like the following:</p>
  
  <pre><code>var audio = new Audio('http://localhost:8000/a.mp3'); // the above
  audio.play();
  </code></pre>
  
  <p>However, as the audio source is a continuous input stream, the content just keeps getting downloaded without end:</p>
  
  <p><a href="https://i.stack.imgur.com/ufYCY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ufYCY.png" alt="Endless downloading"></a></p>
  
  <p>Instead, I want to be able to play the chunks as they are downloaded.</p>
  
  <p>I can access <code>http://localhost:8000/a.mp3</code> in an application like VLC or Quicktime Player, and the audio delivery works fine; I'm just stumped as to how to best do this on the web.</p>
  
  <p>Thanks in advance.</p>