mattvador / node-red-contrib-play-sound Goto Github PK
View Code? Open in Web Editor NEWNode-RED node for play sound
Node-RED node for play sound
Hi Matt,
the sound node plays mp3s fine, but I cannot stop the music. I use a inject node with msg.payload = "stop". It successfully removes the "playing" icon underneath the sound node and triggers the "stop" response on the sound node's output. So I guess the node understands the stop command, because it behaves differently when I send gibberish inputs. But, the music keeps playing nontheless.
I am using a raspberry Pi 3, all updated & upgraded and hdmi sound output. Node Version 6.11.1. Node Red version 0.17.4
Please help me fix this.
Thanks
Hello
I am using this node for a project but we can't manage to pause the music while it is playing. We tried to send a msg.payload containing a 'pause' but this does not do anything. Is there a workauround for this particular problem?
[ { "id": "7cdfcf03214c3a9e", "type": "tab", "label": "Flow 1", "disabled": false, "info": "" }, { "id": "03a768ec195a930d", "type": "PlaySound", "z": "7cdfcf03214c3a9e", "name": "", "playerOptions": "{}", "audioURI": "", "options": "{}", "x": 610, "y": 320, "wires": [ [] ] }, { "id": "d292ad1e58e83da5", "type": "function", "z": "7cdfcf03214c3a9e", "name": "", "func": "msg.audioURI = 'C:\\\\Liedjes\\\\' + Buffer.from(msg.payload);\nreturn msg", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 420, "y": 320, "wires": [ [ "03a768ec195a930d" ] ] }, { "id": "1c40b8fb922a6b73", "type": "inject", "z": "7cdfcf03214c3a9e", "name": "Dancing_in_the_moonlight.mp3", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "Dancing_in_the_moonlight.mp3", "payloadType": "str", "x": 190, "y": 320, "wires": [ [ "d292ad1e58e83da5" ] ] }, { "id": "b43cd90bb1bf6896", "type": "inject", "z": "7cdfcf03214c3a9e", "name": "Pause", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "pause", "payloadType": "str", "x": 430, "y": 380, "wires": [ [ "03a768ec195a930d", "29618bd78cc5c5a4" ] ] }, { "id": "29618bd78cc5c5a4", "type": "debug", "z": "7cdfcf03214c3a9e", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 590, "y": 440, "wires": [] } ]
Kind regards Louis
I have not yet managed to pass anything other than {} in the "Player options" and "Audio-options" fields.
Can you give an example of how options are passed. I want to pass the "-f3000" for the volume to the player mpg123.
What does this mean "If empty, then the one in dialog is used"
hi,
I notice that if NR was started by systemd service manager, this node can not play any song (mp3) with mplayer.
This node generate error log like this:
5 Oct 19:09:19 - [info] [PlaySound:bc151945aaf7784e] Event input: /home/mine/song/003.mp3
5 Oct 19:09:19 - [info] [PlaySound:bc151945aaf7784e] Play: /home/mine/song/003.mp3
5 Oct 19:09:19 - [info] [PlaySound:bc151945aaf7784e] Event exit:0, null
While if NR was started from terminal with just
$ node-red
the node can successfully play/pause/resume/stop the mp3 file with mplayer.
I am using dual core celeron miniPC with 2GB ram, Debian Bullseye without GUI, Node Red 3.0.2, and latest mplayer.
Would you share your thoughts on why this happened?
Hallo
stop pause resume not working
in node-red v0.15.3 raspberry pi
inject (timestamp) -> Play Audio (Audio URI = test1.wav) -> Play Audio (Audio URI = test2.wav)
In this case test1.wav is played twice. Putting a debug to the output of both occurances gets:
5/30/2018, 9:04:33 AMnode: d7c52afd.fac4c
msg : Object
{ _msgid: "c52198df.ca8918", topic: "", payload: "end", audioURI: "/home/pi/test1.wav" }
5/30/2018, 9:04:37 AMnode: 587c7b6f.481e24
msg : Object
{ _msgid: "c52198df.ca8918", topic: "", payload: "end", audioURI: "/home/pi/test1.wav" }
If I use
inject -> change (set msg.audioURI = test1.wav) -> Play Audio -> change (set msg.audioURI = test2.wav) -> Play Audio
or
inject -> Play Audio (Audio URI = test1.wav) -> change (set msg.audioURI = test2.wav) -> Play Audio
then the two different files play.
This is here so anyone else trying to pass options to 'afplay' will have an easier time than I did (grin). This may hold true to other players also.
AFPLAY has many options. If you were using it a CLI setting you would have something like this:
afplay -v 0.5 -t 1.0 -r 0.5 -q 0.5 -d /path/to/soundfile.ext
This says set the volume (-v) to 0.5, play the track for 1 second (-t 1.0), set the speed (-r) to 0.5 (slow), the quality (-q) to .05, debug (-d) and the path to the file: /path/to/soundfile.ext
The path to the file /path/to/soundfile.ext
is set in the node's 'Audio URI' option OR passed to the node in msg.audioURI.
The options (-t, -v etc) are entered in the 'Audio Options' option OR passed to the node in msg.options as a json object using the format: {"afplay": [ "-r", 0.5, "-t", 2.5 ] }
Other players probably use the same format I haven't tested them.
I'm trying to use your node to play sound off a URI (e.g. http://egeland.net/pub/ringtones/Mailroom.mp3).
I've tried passing the inputs you've described in your ReadMe as inputs, including a blank payload but haven't had much luck. Each time I try triggering the node I get the follow error in the debug section:
"TypeError: Cannot read property 'pid' of undefined"
as well as a pop-up alert in Node-Red saying "node-red-contrib-play-sound/play-sound:common.notification.error"
I'm only setting the audioURI setting at the moment (with the link mentioned above) without any options. What pid is the script expecting?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.