最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Streaming music synchronously from a mp3 file via a nodejs server + socket.io - Stack Overflow

programmeradmin1浏览0评论

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 es 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?

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 es 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?

Share Improve this question edited Apr 21, 2019 at 15:42 Cœur 38.8k26 gold badges205 silver badges277 bronze badges asked Feb 10, 2012 at 16:30 codeAnandcodeAnand 9901 gold badge8 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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

https://stackoverflow./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.

发布评论

评论列表(0)

  1. 暂无评论