且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从NodeJS服务器获取实时流式音频到客户端

更新时间:2022-03-19 21:50:07

我在这里参加聚会有点晚了,但它看起来像如果你还没有完成它,那么网络音频API将成为你的朋友。它允许您直接将音频流播放到输出设备,而无需将其附加到音频元素。

I'm a bit late to the party here but it looks like the web audio API will be your friend here, if you haven't already finished it. It allows you to play an audio stream directly to the output device without messing around with attaching it to an audio element.

我正在考虑做同样的事情和你的问题已经回答了我的问题 - 如何从客户端到服务器获取数据。 Web音频API的好处是能够将流一起添加并在服务器上应用音频效果。

I'm looking at doing the same thing and your question has answered my question - how to get data from client to server. The benefit of the web audio API is the ability to add streams together and apply audio effects to it on the server.

MDN Web Audio API

io事件应该是替换音频上下文中音频缓冲区对象中的数据。音频处理可以在nodeJS Web音频上下文中发生,然后作为单个流发送到每个客户端。

The io events should replace the data in an audio buffer object in the audio context. Audio processing can happen in the nodeJS web audio context before being emitted as a single stream to each client.