-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to Stream Audio form the Server to the client ? #73
Comments
Yes it is possible Server io.on('connection', function (socket) {
socket.on('client-stream-request', function (data) {
var stream = ss.createStream();
var filename = __dirname + '/downloads/' + <YOURSONG.MP3>;
ss(socket).emit('audio-stream', stream, { name: filename });
fs.createReadStream(filename).pipe(stream);
});
}); Client var audio = document.getElementById('player');
ss(socket).on('audio-stream', function(stream, data) {
parts = [];
stream.on('data', function(chunk){
parts.push(chunk);
});
stream.on('end', function () {
audio.src = (window.URL || window.webkitURL).createObjectURL(new Blob(parts));
audio.play();
});
}); |
AWESOME, i will try it soon ! <3 THANK YOU VERY MUCH! |
Is it also possible to send additional data with it like Metadata and is it even possible to send it to a specific point of time ? |
You can emit it as a separate event or include it in the data object that is sent with the stream ss(socket).on('audio-stream', function(stream, data) {} |
ok , but what about time sensitive data ? |
Hi, Could you provide the full code? |
With this html part its working:
|
Example over here :D |
is there a way to do it in real time? |
There is a way to stream microphone in a real time, but I have small problem on my implementation.. Update: |
@StefansArya Can I use that library to stream binary blobs (sent as chunks of 3-seconds) ? Finding it very difficult to implement |
Hmm, I think you could only send the buffer data (without media header). Because that's what I can get after calling To stream chunks of 3 seconds you need to change the latency to 3000ms. I have an example on the repository that default to 100ms, maybe you can use that for experimenting. And don't forget to set the similar latency to the streamer too. |
@duncanhoggan , is it a good idea use sockets to build a streaming server to work as a streaming service on demand? |
that doesn't take bandwidth throttling into account no ? I just push as fast as possible no ? |
ss is not defined |
what is ss here ???? |
|
The solution @duncanhoggan provided is working. But what it do is it firstly read the whole file then after that it plays. But What I want is, I want to stream the file into chunks. There can be the delay for max 4-5 seconds. Can anyone please provide the solution for this? |
@rajatlnweb if you send it in chunks of 4-5 seconds, it will play it that way too. |
@avin3sh , Can you please give me the code example as I am not able to find it out anywhere? |
Look above: #73 (comment) |
@zoutepopcorn , I checked your code and it's not related to chunk based audio play at all. |
Could you do that client -> server -> client? |
@jojomoore2007 For that use case I would recommend using WebRTC or something similar, it would scale much better and would be a true peer to peer implementation as opposed to the server middleman. |
Hello And I want all my clients who visit that URL to listen to that music in sync. That is. Let's say the file plays for 6 minutes. I start the song at 10:00 am A request which comes at 10:03 am should start listening from the 3rd minute of the song. All my clients should listen to the song in sync. How can I achieve this with Angular and socket.io? |
Hi @viradiya1993 , did you get any solution for this? |
I also need a solution for this. does anyone know how to implement this? |
Is it possible to Stream Audio form the Server to the client ?
Is there any example please ?
The text was updated successfully, but these errors were encountered: