How do I connect to and send audio to a Bluetooth speaker in Node.js?

Viewed 195

I'm working on creating a Node.js project that can connect to a Bluetooth speaker and send it audio received from several sources (AirPlay, radio stations, etc.).

Currently, I've gotten AirPlay setup and I can receive PCM data from that. Now, I'm trying to figure out how to get that data from Node.js to my Bluetooth speaker.

I've gotten to the point where I can usually connect to the speaker, but it occasionally doesn't work. When it does connect, Ubuntu isn't detecting it as a speaker, just as an "Unknown Bluetooth Device".

I couldn't figure out how to convert from PCM to SBC to send audio through Node.js to the speaker, so I figured that the next easiest thing would to use the speaker package to send audio to the current sound output device. This is not working because Ubuntu isn't detecting it as a speaker.

Even if you can't provide any assistance to fix these problems, I'd love to have some advice on which route I should take as far as connecting and sending audio to the Bluetooth speaker. It would be very nice if this project could be very reliable.

1 Answers

I ended up just using bluetoothctl to connect and get info from the speaker. Once it connects, I'm able to use the speaker module to send audio to it.

Related