As from socket.io website
Binary streaming
Starting in 1.0, it's possible to send any blob back and forth: image, audio, video.
I'm now wondering, if this couldn't be the solution for something I'm trying to achieve recently.
I'm actually looking for a way how to broadcast live audio stream from (A - ie, mic input..) to all clients connected to a website of mine. Is something like this possible? I've been messing with WebRTC (https://www.webrtc-experiment.com/) examples but I haven't been able to manage the goal for more than few connected clients.
My idea is about something like getUserMedia or any other audio source (PCM, whatever..) on side A being chopped to chunks and provided to client and played for example by html5 audio element or anything.. I need to make that stream as much realtime as possible, no shout/ice cast services werent fast enough (indeed, they arent solution to my problem, they're meant to be used this way) and I don't really care about the audio quality. Crossplatform compatibility would be awesome.
Is something like that possible? By using socket.io as way how to provide those data to clients?
I would be very grateful for any reference, hint or source that could help me achieve this. Thanks a lot.
This example shows you how to use the
MediaRecorder
to upload audio and then forward it usingsocket.io
. This code will only broadcast after you're calledmediaRecorder.stop()
. You can choose to broadcast inside ofondataavailable
. If you do that, you might want to pass atimeslice
tomediaRecorder.start()
, so that it doesn't triggerondataavailable
so often.This solution isn't truly live, but I think it will help people who come back and find this question.
Client Code
Server Code
In the Client Code you can write setInterval() instead of setTimeout() and then recursively call mediaRecorder.start() so that every 5 seconds the blob will be emitted continuously.
Client Code
Server Code
you may see this demo https://github.com/LingyuCoder/SkyRTC-demo hope some help