Node.js Speaker isssue

Good morning everyone,

Since 2 month I'm working on a node.js mp3 player on my raspberry pi. I used the npm package player (https://www.npmjs.com/package/player) which worked fine with the defaut raspberry jack.

Last week, I order a HifiBerry DAC Standard phone jack to get a better sound. I've installed everything with the tutorial (https://www.hifiberry.com/guides/configuring-linux-3-18-x/). My player load the first music and everything it's ok. But when I need to play the second music on the playlist (Player.next), the program breaks. That never happen before with the defaut rapsberry sound card. Program logs :

im playing... src:"DCUP - Im Corrupt (Viceroy remix).mp3"
[ 'Breakbot - Star Tripper (Audio Only).mp3',
'Star Tripper (Audio Only)',
index: 0,
input: 'Breakbot - Star Tripper (Audio Only).mp3' ]
add /media/pi/C120-CF33/Musiques/Breakbot - Star Tripper (Audio Only).mp3 , 57af194fb23a40049c5b25a7
im playing... src:"Breakbot - Star Tripper (Audio Only).mp3"
[../deps/mpg123/src/output/alsa.c:165] error: cannot open device default
throw er; // Unhandled 'error' event

Error: open() failed: -1
at Speaker._open (/home/pi/node/music_project/node_modules/player/node_modules/speaker/index.js:168:11)
at Speaker._write (/home/pi/node/music_project/node_modules/player/node_modules/speaker/index.js:242:21)
at doWrite (/home/pi/node/music_project/node_modules/player/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/pi/node/music_project/node_modules/player/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Speaker.Writable.write (/home/pi/node/music_project/node_modules/player/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at Volume.ondata (_stream_readable.js:556:20)
at emitOne (events.js:96:13)
at Volume.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:177:18)
at Volume.Readable.push (_stream_readable.js:135:10)



The main message error is [../deps/mpg123/src/output/alsa.c:165] error: cannot open device default . I think alsa is not configured correctly. My etc/asound.conf :

pcm.!default {
type hw card 0
ctl.!default {
type hw card 0

I don't understand why alsa cannot get the defaut device only on the second music. Alsa.c is a part of the speaker package ; it's used to send sound to the sound card. You can find sources here : https://www.npmjs.com/package/speaker


Does anybody have any idea of what happen here ?

Thank you

Rémi Bruyère


Please sign in to leave a comment.