Play (live) audio using HTML5 by streaming from a WebSocket connection.
This is an experimental project that has only been tested in Google Chrome.
You will need a WebSocket audio stream to play from - example project for how to do this here.
- Include
dist/wsaudio.js
anddist/worker.js
in your app - Reference
dist/wsaudio.js
in your page - Create a new
WsAudio
object
<audio id="audio" autoplay="autoplay" controls="controls"></audio>
<script type="text/javascript" src="dist/wsaudio.js"></script>
<script type="text/javascript">
var wsAudio = new WsAudio(document.getElementById('audio'), 'ws://localhost:5001/stream', 'dist/worker.js');
</script>
See demo.html for an example.