Want to pause one audio until the second one done and restart the first one again

Hi, I am new to Node-red and want to create two ui-audio node with this conditions
1- First audio play in background.
2- when second audio start the first audio paused,
3- when the second audio finish, the first audio plays from beginning.

I tried different solutions such as switch node, but always there is an overlap between both audios

Hi, maybe this example will help.
Add your mp3/audio files paths in the inject nodes.
Click mp3 1, it should play. Then click mp3 2, that should override mp3 1, and when mp3 2 finishes the flow should restart mp3 1.

[{"id":"b46f552159f84cdc","type":"inject","z":"65617ffeb779f51c","name":"mp3 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"playing","payload":"/storage/emulated/0/Download/sample-1.mp3","payloadType":"str","x":70,"y":1240,"wires":[["4839a4b77a5ba5c6"]]},{"id":"4839a4b77a5ba5c6","type":"rbe","z":"65617ffeb779f51c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"topic","topi":"topic","x":230,"y":1260,"wires":[["785d2ce7ae226099"]]},{"id":"ad4870c578e3608b","type":"inject","z":"65617ffeb779f51c","name":"mp3 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"override","payload":"/storage/emulated/0/Download/sample-2.mp3","payloadType":"str","x":70,"y":1280,"wires":[["4839a4b77a5ba5c6"]]},{"id":"785d2ce7ae226099","type":"join","z":"65617ffeb779f51c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":230,"y":1320,"wires":[["b87e531af1defa7c"]]},{"id":"2ec7bd6dcb65a704","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"playing","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"playing","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1380,"wires":[["785d2ce7ae226099"]]},{"id":"b87e531af1defa7c","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"playing","pt":"flow","to":"payload.playing","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[msg.topic]","tot":"msg"},{"t":"set","p":"topic","pt":"flow","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1320,"wires":[["e4cb650209ec709e"]]},{"id":"ccec82d80d0cc04f","type":"switch","z":"65617ffeb779f51c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"playing","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":1380,"wires":[["2ec7bd6dcb65a704"]]},{"id":"e4cb650209ec709e","type":"file in","z":"65617ffeb779f51c","name":"","filename":"payload","filenameType":"msg","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":540,"y":1320,"wires":[["78488737a037060b"]]},{"id":"788d0c408b3681e7","type":"switch","z":"65617ffeb779f51c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"prev"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":1440,"wires":[["138d998d4718ad3a","ccec82d80d0cc04f"]]},{"id":"78488737a037060b","type":"trigger","z":"65617ffeb779f51c","name":"","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"50","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":690,"y":1320,"wires":[["213ed8ab5d054e2b"],["5437b19e5ab80c65"]]},{"id":"289c4d50efb83e1c","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"topic","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1440,"wires":[["e01c778b0142e9ac","788d0c408b3681e7"]]},{"id":"138d998d4718ad3a","type":"debug","z":"65617ffeb779f51c","name":"debug 256","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":1440,"wires":[]},{"id":"213ed8ab5d054e2b","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1320,"wires":[["5437b19e5ab80c65"]]},{"id":"5437b19e5ab80c65","type":"ui_audio","z":"65617ffeb779f51c","name":"","group":"2d4fe667.28f8ba","voice":"English United Kingdom","always":true,"x":860,"y":1360,"wires":[]},{"id":"be1985019578187c","type":"switch","z":"65617ffeb779f51c","name":"","property":"status","propertyType":"msg","rules":[{"t":"hask","v":"text","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":1440,"wires":[[],["289c4d50efb83e1c"]]},{"id":"e01c778b0142e9ac","type":"debug","z":"65617ffeb779f51c","name":"debug 257","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":1380,"wires":[]},{"id":"ea4d8b35f2b21f3b","type":"status","z":"65617ffeb779f51c","name":"","scope":["5437b19e5ab80c65"],"x":100,"y":1440,"wires":[["be1985019578187c"]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

How to import a flow

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