# Music from a file

**URL:** https://discourse.nodered.org/t/music-from-a-file/48335
**Category:** General
**Created:** [12 July 2021 19:54 UTC](https://discourse.nodered.org/t/music-from-a-file/48335 "2021-07-12T19:54:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jackob25](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@Jackob25](https://discourse.nodered.org/u/Jackob25)
#### Post date: [12 July 2021 19:54 UTC](https://discourse.nodered.org/t/music-from-a-file/48335/1 "2021-07-12T19:54:40Z")

</div>

I'm not sure the best way to make a system that pauses, plays and restarts music from a sound file that's on the machine. This is what I have so far and I can't get it to work... I have scrolled through and keep finding people using the http node(s) and I wanted to use the 'file-in' and 'audio-out' nodes. I haven't found anyone whose had experience with this, and I know i'm missing something but after hours of this and not being able to figure it out...if anyone can just point me in the direction of what to read then I think I can get it from there.

```auto
[{"id":"19636e55.bb21a2","type":"ui_button","z":"ca6973d9.194ca","name":"","group":"3346acfc.8202b4","order":1,"width":"1","height":"1","passthru":false,"label":"Start Music","tooltip":"","color":"Black","bgcolor":"light green","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":370,"y":180,"wires":[["559fe2ae.aefc5c"]]},{"id":"1bfec392.cd706c","type":"ui_button","z":"ca6973d9.194ca","name":"","group":"3346acfc.8202b4","order":3,"width":"1","height":"1","passthru":false,"label":"Reset Music","tooltip":"","color":"White","bgcolor":"Black","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":370,"y":340,"wires":[["f6730570.2d93c8"]]},{"id":"559fe2ae.aefc5c","type":"change","z":"ca6973d9.194ca","name":"","rules":[{"t":"set","p":"musicState","pt":"global","to":"playing","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":220,"wires":[[]]},{"id":"f6730570.2d93c8","type":"change","z":"ca6973d9.194ca","name":"","rules":[{"t":"set","p":"musicState","pt":"global","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":360,"wires":[[]]},{"id":"e6699e8b.23e79","type":"comment","z":"ca6973d9.194ca","name":"Music","info":"","x":350,"y":140,"wires":[]},{"id":"1a8e3816.0ec978","type":"play_audio_file","z":"ca6973d9.194ca","filename":"/home/jacob/Downloads/THNDR.mp3","x":540,"y":460,"wires":[["d09d5c1b.563c3"]]},{"id":"c7806677.07fcc8","type":"inject","z":"ca6973d9.194ca","name":"play","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Playing","payloadType":"msg","x":390,"y":220,"wires":[["559fe2ae.aefc5c"]]},{"id":"d09d5c1b.563c3","type":"ui_audio","z":"ca6973d9.194ca","name":"","group":"59b49b1a.fdf564","voice":"","always":"","x":720,"y":460,"wires":[]},{"id":"fe0afdd2.318d","type":"ui_button","z":"ca6973d9.194ca","name":"","group":"3346acfc.8202b4","order":1,"width":"1","height":"1","passthru":false,"label":"Pause Music","tooltip":"","color":"Black","bgcolor":"light green","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":370,"y":260,"wires":[["62a9a699.197698"]]},{"id":"62a9a699.197698","type":"change","z":"ca6973d9.194ca","name":"","rules":[{"t":"set","p":"musicState","pt":"global","to":"stopped","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":300,"wires":[[]]},{"id":"addfd2d.f2f253","type":"inject","z":"ca6973d9.194ca","name":"Pause","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"msg","x":390,"y":300,"wires":[["62a9a699.197698"]]},{"id":"f9c30b23.750648","type":"inject","z":"ca6973d9.194ca","name":"Restart","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"musicState","payloadType":"global","x":390,"y":380,"wires":[["f6730570.2d93c8"]]},{"id":"3346acfc.8202b4","type":"ui_group","name":"Music","tab":"5c030594.084acc","order":5,"disp":false,"width":"6","collapse":false},{"id":"59b49b1a.fdf564","type":"ui_group","name":"","tab":"f976c216.1eb41","order":3,"disp":true,"width":"6","collapse":false},{"id":"5c030594.084acc","type":"ui_tab","name":"Game Master","icon":"dashboard","disabled":false,"hidden":false},{"id":"f976c216.1eb41","type":"ui_tab","name":"Escape Room","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [12 July 2021 20:11 UTC](https://discourse.nodered.org/t/music-from-a-file/48335/2 "2021-07-12T20:11:42Z")

</div>

Hi, in order to make code more readable and importable it is important to surround your code with three backticks  
`````  
`like this`  
`````

You can edit and correct your post by clicking the pencil icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [10 September 2021 20:12 UTC](https://discourse.nodered.org/t/music-from-a-file/48335/3 "2021-09-10T20:12:10Z")

</div>

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