webaudio-wav-stream-player

instantly play remote wav streams using fetch API + WebAudio

Downloads
33
Stars
39

webaudio-wav-stream-player

No latency wav stream player using browser fetch streaming API and WebAudio

Tested on Chrome and Firefox 57+ with some flags on.

Example : http://revolunet.github.io/webaudio-wav-stream-player

Based on @chrisguttandin and @revolunet work

Usage

import WavPlayer from 'webaudio-wav-stream-player';

let player = new WavPlayer();
player.play('http//domain/path/to/stream.wav');
player.stop();

FAQ

  • you need CORS on the server streaming .wav

Example express proxy to add CORS header to some remote uri

// proxy /proxy/http://path/to/stream.wav

app.get('/proxy/*', function (req, res, next) {
  let remoteReq = request.get(req.params[0]);
  req.on("close", function() {
      remoteReq.abort();
      res.end();
  });
  req.pipe(remoteReq).pipe(res);
});

Inspiration : http://stackoverflow.com/questions/38589614/webaudio-streaming-with-fetch-domexception-unable-to-decode-audio-data/39988015#39988015