I am trying to play a pcm audio stream from a websocket in a react application.
On the backend I have a websocket that streams pcm audio. I was able to create a node file that would connect to the websocket pcm stream and play the audio through my computer speakers using the npm packages websocket-stream
and speaker
.
The issue I am having now is how to move this code over to a react application. When I try to use the websocket-stream
package in react, the application does not compile. In addition, the speaker
package does not seem to work in the browser. I have found a few examples of playing mp3 files in react, but none that play from a stream.
Any help/direction would be greatly appreciated!
I used this github project and ported the code over to a react app: https://github.com/samirkumardas/pcm-player