简体   繁体   中英

Streaming music synchronously from a mp3 file via a nodejs server + socket.io

I have a mp3 file on my server.

And i want all my clients who visit that url to listen to that music in sync.

That is.

Lets say the file plays for 6 minutes.

I start the song at 10:00am

A request which comes at 10:03am 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 nodejs and socket.io?

EDIT: If you want to do exactly what was asked the answer on the link is a much better match:

https://stackoverflow.com/a/26029102/67945

My original answer looses itself on the benefits of ipv4 multicasting.


What you are looking for is streaming.

The benefits added to the usage of streaming (opposed to every client having it's own open connection) are specially visible as your listeners base grow but the feed remains using the same bandwidth. Else you would grow into bandwidth problems pretty fast.

Streaming is a protocol (as http) and you can check a list of Streaming Servers here .

A very popular (and free) streaming server is IceCast .
And with a little Flash you can have a client player .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM