简体   繁体   English

通过nodejs服务器+ socket.io从mp3文件同步流音乐

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

I have a mp3 file on my server. 我的服务器上有一个mp3文件。

And i want all my clients who visit that url to listen to that music in sync. 我希望所有访问该URL的客户都能同步收听该音乐。

That is. 那是。

Lets say the file plays for 6 minutes. 可以说文件播放了6分钟。

I start the song at 10:00am 我从上午10:00开始播放歌曲

A request which comes at 10:03am should start listening from the 3rd minute of the song. 上午10:03发出的请求应从歌曲的第三分钟开始收听。

All my clients should listen to the song in sync. 我所有的客户都应同步收听歌曲。

How can I achieve this with nodejs and socket.io? 如何使用nodejs和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 https://stackoverflow.com/a/26029102/67945

My original answer looses itself on the benefits of ipv4 multicasting. 我最初的答案是对ipv4多播的好处失去了信心。


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 . 流是一个协议(如http),您可以在此处检查流服务器的列表

A very popular (and free) streaming server is IceCast . IceCast是一个非常流行(免费)的流媒体服务器。
And with a little Flash you can have a client player . 只需一点Flash,您就可以拥有一个客户端播放器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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