Context:
I'm developing audio app on Node.js for RPI on Rapsberry PI OS Lite (Debian, no GUI), and I need the way of playing mp3 files in the Node.js env from https with the ability to pause/resume the playback. I need this to be working on Mac M1 (dev/debug) and on the RPI.
Surprisingly for me, I didn't find any working audio player for mac/linux that would solve this out of the box (spent a few hours searching and trying different options).
Possible solution
I am trying to implement the playback with the following approach: mp3 -> PCM stream -> speaker, that looks relatively straight-forward, smth like this:
import https from "https";
import prism from "prism-media";
import Speaker from "speaker";
decoder = new prism.FFmpeg({...});
speaker = new Speaker({...});
play(url) {
this.stream = https.get(url, (response) => {
response.pipe(this.decoder).pipe(this.speaker);
});
}
pause() {
this.decoder.unpipe(this.speaker);
}
resume() {
this.decoder.pipe(this.speaker);
}
The problem
The speaker package fails to install on Mac M1 with Node v21.7.
Then I found this fork of the arm64 support, which also fails to install with:
...
npm ERR! ../deps/mpg123/src/mpg123app.h:14:10: fatal error: 'config.h' file not found
...
Then I found the audio-speaker package that looks promissing, but it also fails on initialisation with this.
I don't give it up, but I am afraid I am running out of options I can come up with on my own. I would appreciate any feedback.