Pulseaudio and musicplayer

Hello.

I try to get a song being played by a musicplayer with console input. For audio output i use Pulseaudio to send the song to a dlna loudspeaker.

For example: "cvlc /mount/music/song.mp3"

This works perfect as long as i do it in a normal terminal window. But when I try this with the node "exec" I get the error message: "vlcpulse audio output error: PulseAudio server connection failure: Verbindung verweigert (means connection forbidden). So it seems the Pulseaudio doesnt allow connection if i call the music program from node red. If i use ssh from node red to call the program (127.0.0.1) it also works. But ssh makes to many problems with connect and disconnect.

Is there any way to fix this and to call a msuciprogram from node red? It can be also a different program like mplayer or similar.

Thanks in advance

1 Like

Here you can see. On the left is when i start mplayer in a normal terminal. On the right is the same in node-red when starting in xterm. At the bottom you see the:

AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
Could not open/initialize audio device -> no sound.

Why does it work in terminal but not in node-red? Has it to do with any permission?

This looks like a permission issue. Most probably pulse is running as a different user than the one you run node-red with. You can run pulse in system wide mode but this has some caveats that are for example described here:

Or you have to run pulse and node-red with the same user.

Johannes

Sorry for the late reply. I tried that out and it worked. Now i am at the point that mplayer is playing the song in the node red with the exec node. I can see it is playing from the debug output but i hear no sound over the dlna speaker. This is the output from the dubug:

MPlayer 1.3.0 (Debian), built with gcc-8 (C) 2000-2016 MPlayer Team

Terminal type `unknown' is not defined.

Playing /mount/musik/alte.mp3.
libavformat version 58.20.100 (external)
Audio only file format detected.
Clip info:
Title: Die alte HĂżhnermutter
Artist: Revolverheld
Album: Giraffenaffen 2
Year:
Comment:
Genre: Unknown
Load subtitles in /mount/musik/

Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III

AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)

AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)

Video: no video
Starting playback...

A: 0.0 (unknown) of 209.0 (03:29.0) ??,?%
A: 0.0 (00.0) of 209.0 (03:29.0) ??,?%
A: 0.1 (00.0) of 209.0 (03:29.0) ??,?%
A: 0.3 (00.2) of 209.0 (03:29.0) 0.8%
A: 0.5 (00.4) of 209.0 (03:29.0) 0.9%
A: 0.6 (00.5) of 209.0 (03:29.0) 0.9%
A: 0.8 (00.7) of 209.0 (03:29.0) 0.8%
A: 0.9 (00.9) of 209.0 (03:29.0) 0.8%
A: 1.1 (01.1) of 209.0 (03:29.0) 0.8%
A: 1.3 (01.3) of 209.0 (03:29.0) 0.8%
A: 1.5 (01.5) of 209.0 (03:29.0) 0.8%
A: 1.7 (01.6) of 209.0 (03:29.0) 0.8%

If I play it in normal terminal window i can see it it the dlna messages that the song is being handed over to the speaker but here nothing. And i have the pavucontrol installed. Same here: When i play the song in terminal i see an input here. With node red nothing. But the song must be played from what i see in the debug log.

Are you sure it’s playing to the right output. Can you specify the output to play too in mplayer?

I could set the output with the option -AO. But it seems to be pulse as standard output. In the text above it can be seen here : AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.