i try to play music with the raspberry and also play random sound effects at the same time.
i followed this tutorial: http://pacmans-revenge.blogspot.com/2018/08/raspberry-pi-bluetooth-speakers.html
but it doesnt work like i want it to. while i am connected with my mobile to the raspberry and stream a song, i can run a music file from the terminal, but i can not trigger it with the same command from nodered.
okay i made a little work around ... my new strategy is to just build up an ssh connection inside nodered and send the play commands via that method. now the only problem i got is that the ssh connection does allways close after one command. anyone knows a strategy ?
You can send commands one at a time using ssh using ssh user@server "some_command to execute remotely with params"
That way you don't need to build and maintain the connection.
Hi, thanks for your help. Now it open the ssh connection without authentification via passwort and uses instead a key file.
My problem is, that everytime it open the connection, there is about 500ms delay. if i want to play an audiosample just in time, this is a problem.
so i need to have an connected ssh tunnel which, after first connection, can be used to pump more commands to that established connection... any idea how to do that in nodered ?
but that is just another way to pump a command to the exec node. the problem still is, that the command "play /dedo.wav" pumped in the exec node doesnt work. i have to use a terminal or a ssh connection to be able to play a soundfile.
i still got the problem which i mentioned in the picture i postet at my thread start.
the ssh connection was just a work around.
If you are playing the music on the Pi and have the speakers attached to it, have you tried using node-red-contrib-playsound? Not sure if it will work with bluetooth speakers, but it worked fine in my Music Player project
OK, worked that out myself "Error opening device or file not found".
Put a debug node showing what is going into the exec node and also show us the config of the exec node.
Hello,
You get this error because alsa cant play two things at once. This is why alsa gives you the resource busy error.
If you ll want to play several things to one audio output at the same time you will have to use a middleware soundserver like pulseaudio to do it im afraid. You seem to be using pulse audio for your music so you would need to play whatever you want to play from nodered through pulse audio too. Aplay tries to play it directly it seems. If you have the pulse audio utils installed you could try use paplay instead of aplay.
Johannes
Seems there is also a problem with some permissions or something when i try to pump that command though the exec node. Via Putty it works just fine, also when iam playing in that moment a song from my mobilephone via bluetooth.
your missing a / at the start of you file path it should be something like /home/pi/your_audio.wav. That’s probably why your getting the error that the file couldn’t be found and you shouldn’t need sudo.