Audio file playback and stopping playback

Hello all,

I am very new to Node-red. So I am hoping I am just missing something obvious.

I have a Raspberry Pi3 running Node-red 0.19.6, node.js 10.15.1

I am trying to play a local sound file (.Wav) on the mini-jack output.
This works as expected by using the "Play_sound" node into a "Play_audio" node.
What is not working is stopping the Audio file.
in the description of the node it says to send "msg.payload ; stop"
I have tried all variations of this that I can think off, but I cant get it to work.
it always plays out to the end of the file.
is there any way of doing this?

all help is appreciated.

Put a debug node showing what you are sending to stop it and paste the result here.
Also please confirm which node you are using to play it. Is it a node-red-contrib-something node?

Just to check, you are not setting msg.payload to "msg.payload: stop" are you? I imagine it means that you should set msg.payload to "stop".

Hi Colin,

thanks for responding;
I am using
node-red-contrib-play-sound

I am sending a msg.payload string "stop"
I pasted the debug output.

pi/15 : msg.payload : string[4]

"stop"

I have also tried to use a change node and make the msg.stop this has no effect...

thanks for your help.

Sander

Can you make a test flow consisting of the play node and some inject nodes to start/stop it so we can try it ourselves? Post that here.

Hi Colin,

I have not done this before, so I hope this works.
The sound file that is referenced in the flow is local on my pi.
It would have to be replaced with something on your end.

Thanks

Sander

[{"id":"a992881b.240248","type":"tab","label":"send to forum","disabled":false,"info":""},{"id":"1226b862.a3c8a8","type":"PlaySound","z":"a992881b.240248","name":"hello","playerOptions":"{}","audioURI":"/home/pi/Music/Hello.wav","options":"{}","x":550,"y":281,"wires":[["7051e885.492bf8","ff1b253a.d96ec8"]]},{"id":"7051e885.492bf8","type":"play audio","z":"a992881b.240248","name":"","voice":"0","x":901,"y":273,"wires":[]},{"id":"ff1b253a.d96ec8","type":"debug","z":"a992881b.240248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":899.5,"y":315,"wires":[]},{"id":"56121db3.5b1d04","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"play","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":174.5,"y":245,"wires":[["1226b862.a3c8a8"]]},{"id":"e2fbba98.02b158","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":183.5,"y":312,"wires":[["1226b862.a3c8a8"]]}]

Please see this on how to share a flow. You can go back and edit the previous message.

Thanks,
here it is
Sander

[{"id":"1226b862.a3c8a8","type":"PlaySound","z":"a992881b.240248","name":"hello","playerOptions":"{}","audioURI":"/home/pi/Music/Hello.wav","options":"{}","x":550,"y":281,"wires":[["7051e885.492bf8","ff1b253a.d96ec8"]]},{"id":"7051e885.492bf8","type":"play audio","z":"a992881b.240248","name":"","voice":"0","x":901,"y":273,"wires":[]},{"id":"ff1b253a.d96ec8","type":"debug","z":"a992881b.240248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":899.5,"y":315,"wires":[]},{"id":"56121db3.5b1d04","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"play","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":174.5,"y":245,"wires":[["1226b862.a3c8a8"]]},{"id":"e2fbba98.02b158","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"pause","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":163.5,"y":312,"wires":[["1226b862.a3c8a8"]]}]

You have another node there that you have not said what it is. The play audio node. But I don't understand why you need both.

aha, you are right.
that only plays the audio in the browser.
I just tried to take that our and it still works.
but the "stop" still has no effect.

it is this now

[{"id":"1226b862.a3c8a8","type":"PlaySound","z":"a992881b.240248","name":"hello","playerOptions":"{}","audioURI":"/home/pi/Music/Hello.wav","options":"{}","x":562,"y":284,"wires":[["ff1b253a.d96ec8"]]},{"id":"ff1b253a.d96ec8","type":"debug","z":"a992881b.240248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":903.5,"y":294,"wires":[]},{"id":"56121db3.5b1d04","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"play","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":174.5,"y":245,"wires":[["1226b862.a3c8a8"]]},{"id":"e2fbba98.02b158","type":"inject","z":"a992881b.240248","name":"","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":174.5,"y":311,"wires":[["1226b862.a3c8a8"]]}]

Well unfortunately I can't make it go at all (on Ubuntu) , so difficult for me to test. However there is this issue on the node which might be relevant.

Hi Colin,

that is indeed relevant...

Do you know of any other Nodes that would play a sound file (and are stoppable?)

thanks
for your help

Sander

I don't, sorry. Someone else may. I don't know why that issue was closed, it appears to be a bug in the node.

I think I will report it again. maybe it can be fixed.

thanks a lot for your help

Sander

You said in your first post you were using the Jack output, the issue says it is ok on the jack, but not on the hdmi.
Also I notice the node does not even produce an error if it can't find the file, which seems odd.

Indeed.

I also have now forced the raspi-config to the jack output. No difference.

Trying to figure out if I can set the volume to zero or something else.

Thanks for your help

Also worth reopening / opening a new issue, so that the author knows it is still a problem