# Playing mp3 Audio

**URL:** <https://discourse.nodered.org/t/playing-mp3-audio/8188>\
**Category:** General\
**Created:** [20 February 2019 14:46 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188 "2019-02-20T14:46:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [20 February 2019 14:46 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/1 "2019-02-20T14:46:38Z")

</div>

Hi, I am new to Node Red and am trying to get it play an mp3 file. I have installed three modules but can't get any of them to work. Any help would be appreciated.  
These are the three modules that I tried to use:  
node-red-contrib-play-sound  
node-red-contrib-play-audio  
node-red-contrib-play-audio-file  
Thanks,  
M.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 February 2019 14:51 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/2 "2019-02-20T14:51:22Z")

</div>

So where are you running Node-RED? Operating System, version of Node-RED version of Nodejs

Where do you want the sound to play? On the machine running Node-RED or on the machine displaying the browser?

Have you looked at the the logs to see if there are any error messages?

---

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [20 February 2019 15:14 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/3 "2019-02-20T15:14:45Z")

</div>

Thanks for your quick reply!  
Running on Windows 10  
Node-RED version: v0.19.5.  
Node.js version: v10.15.1

At the moment I am trying to play it in the browser of the machine that is running node red. Later I would like to play it on a Bluetooth speaker. In the console I am getting the following errors:

TypeError: Cannot read property 'pid' of undefined  
at PlaySound\_Node.node.play (C:\Users\mecky.node-red\node\_modules\node-red-contrib-play-sound\node-red-contrib-play-sound.js:59:27)  
at C:\Users\mecky.node-red\node\_modules\node-red-contrib-play-sound\node-red-contrib-play-sound.js:112:10  
at Layer.handle [as handle\_request] (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\layer.js:95:5)  
at next (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\route.js:137:13)  
at C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\red\api\auth\index.js:63:13  
at Layer.handle [as handle\_request] (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\layer.js:95:5)  
at next (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\route.js:137:13)  
at Route.dispatch (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\route.js:112:3)  
at Layer.handle [as handle\_request] (C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\layer.js:95:5)  
at C:\Users\mecky\AppData\Roaming\npm\node\_modules\node-red\node\_modules\express\lib\router\index.js:281:22

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 February 2019 16:30 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/4 "2019-02-20T16:30:55Z")

</div>

So I'm pretty sure that node-red-contrib-play-sound works on the server that Node-RED is running on NOT from the browser.

If you want it to work in the browser you will need to use node-red-contrib-play-audio

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [20 February 2019 17:48 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/5 "2019-02-20T17:48:52Z")

</div>

Note : recently many browsers stopped/blocked auto play of audio files (to be less annoyiing advert wise) - and this may stop the browser side nodes from working.

---

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [20 February 2019 19:06 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/6 "2019-02-20T19:06:36Z")

</div>

I am fine if it plays on the sever or the browser but cannot get any of them to work.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 February 2019 19:30 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/7 "2019-02-20T19:30:19Z")

</div>

Great! Now you choose one and hopefully the community can help work out why its not working.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [20 February 2019 20:22 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/8 "2019-02-20T20:22:45Z")

</div>

Hey Mecky,

For playing sound in the browser, I currently use the following two nodes in my flow:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/663a8e5a6304ef45166e2465a10d922f0fd9b56c.png)

The dashboard's _audio-out_ node plays sound in my _ **dashboard** _, and the _node-red-contrib-play-audio_ node plays sound in my _ **flow editor** _. So both nodes play sound in the browser, but for two different applications ...

---

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [20 February 2019 23:37 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/9 "2019-02-20T23:37:48Z")

</div>

Hi Bart,

can you play a mp3 file with those? If so, could you send me an example of how to set them up?

Thanks,  
Mecky

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [21 February 2019 06:10 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/10 "2019-02-21T06:10:25Z")

</div>

Hmmm, I think it is WAV. Will try this evening MP 3. Now I'm off to my great place to work 🤥

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [21 February 2019 23:10 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/11 "2019-02-21T23:10:41Z")

</div>

Hey Mecky,

Have tested it with following flow, which downloads an mp3 from the web and plays it in the browser:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/88f5700fde01f88bf84f1ea5b6f1e756e0aa9405.png)

```auto
[{"id":"2a8146bc.01fa8a","type":"http request","z":"47b91ceb.38a754","name":"Download m3","method":"GET","ret":"bin","url":"https://www.thesoundarchive.com/email/mp_grail.mp3","tls":"","x":1260,"y":160,"wires":[["b4e7058c.12e0d8"]]},{"id":"7e9367c2.5c3018","type":"inject","z":"47b91ceb.38a754","name":"Start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1070,"y":160,"wires":[["2a8146bc.01fa8a"]]},{"id":"b4e7058c.12e0d8","type":"ui_audio","z":"47b91ceb.38a754","name":"","group":"16a1f12d.07c69f","voice":"0","always":true,"x":1460,"y":160,"wires":[]},{"id":"ca47e138.e7016","type":"comment","z":"47b91ceb.38a754","name":"Play mp3 in dashboard","info":"","x":1100,"y":120,"wires":[]},{"id":"fb9523fe.0686d","type":"http request","z":"47b91ceb.38a754","name":"Download m3","method":"GET","ret":"bin","url":"https://www.thesoundarchive.com/email/mp_grail.mp3","tls":"","x":1260,"y":260,"wires":[["4b104bb8.b27cd4"]]},{"id":"9fa09162.6a45b","type":"inject","z":"47b91ceb.38a754","name":"Start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1070,"y":260,"wires":[["fb9523fe.0686d"]]},{"id":"f9554a1d.16f3d8","type":"comment","z":"47b91ceb.38a754","name":"Play mp3 in flow editor","info":"","x":1100,"y":220,"wires":[]},{"id":"4b104bb8.b27cd4","type":"play audio","z":"47b91ceb.38a754","name":"","voice":"","x":1470,"y":260,"wires":[]},{"id":"16a1f12d.07c69f","type":"ui_group","z":"","name":"Default","tab":"f136a522.adc2a8","order":1,"disp":true,"width":"6"},{"id":"f136a522.adc2a8","type":"ui_tab","z":"","name":"Home","icon":"home","order":1}]

```

I run Node-RED on a Raspberry PI 3 model B and did the tests in browsers on Windows 10. It works fine in Chrome/Firefox/Edge both for flow editor and dashboard. So **6 tests** in total ...

A couple of remarks:

- The output of my http-request node is binary buffer. Don't convert audio or video anywhere to strings ...
- In the audio-out node I have selected the checkbox '_Play audio when window not in focus_, because it won't play otherwise when the tab (where you have added your audio-out node) isn't visible at the moment ...

---

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [22 February 2019 02:13 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/12 "2019-02-22T02:13:59Z")

</div>

Thanks Bart! Is it possible to grab the mp3 from the local computer too? Instead of a http request, what would I have to use?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 February 2019 06:13 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/13 "2019-02-22T06:13:59Z")

</div>

I used the http-request node to make sure you have 'exact the same' data as in my tests. If that works in your case (???), then you know at least that the browser isn't your problem...

I think you just need to use the file-in node. But make sure you specify binary output (instead of string or text or whatever)!!!!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 February 2019 08:50 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/14 "2019-02-22T08:50:08Z")

</div>

@meckyreuss - if by 'local computer' you mean the computer running the browser, the file-in node reads the file only from the machine NR is running on.

If the browser is running on the machine NR is running on, it will work, but it the browser is runnig on 'A' and NR is running on 'B' the file-in node can only read files from 'B'

---

<div class="post-metadata">

**Author:** ![meckyreuss](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meckyreuss/32/6161_2.png) [@meckyreuss](https://discourse.nodered.org/u/meckyreuss)\
**Post date:** [22 February 2019 14:50 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/15 "2019-02-22T14:50:56Z")

</div>

Works like a charm!!! Is there a possibility to

1. add a stop, pause and rewind into the flow?
2. add a timer that triggers events at predefined times?

Thanks!  
Mecky

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 February 2019 16:06 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/16 "2019-02-22T16:06:45Z")

</div>

> [@meckyreuss](#):
>
> add a stop, pause and rewind into the flow?

- We added a **stop** functionality some time ago via this [pull-request](https://github.com/node-red/node-red-dashboard/pull/449) (via `msg.reset`).
- The **rewind** is certainly not implemented.
- When you look at the [discussion](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/20) (related to that pull request), we _didn't_ add **pause** functionality in that pull-request. Reason is that web audio doesn't support pause/resume out-of-the-box. There are workarounds to get it done, but I don't have the time at the moment to implement that...

> [@meckyreuss](#):
>
> add a timer that triggers events at predefined times?

Yes you can use the Interval-node, Inject-node, BigTimer-node ... There are plenty examples available when you search in Google or in this forum.

---

<div class="post-metadata">

**Author:** ![Statler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/statler/32/32541_2.png) [@Statler](https://discourse.nodered.org/u/Statler)\
**Post date:** [26 July 2019 23:53 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/17 "2019-07-26T23:53:57Z")

</div>

You saved my day. Thanks a lot for posting this here

---

<div class="post-metadata">

**Author:** ![tiby007](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tiby007](https://discourse.nodered.org/u/tiby007)\
**Post date:** [3 July 2020 19:08 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/18 "2020-07-03T19:08:53Z")

</div>

Hello Everyone!

I am new to Node-RED, but I feel we will be friends 🙂  
I want to play a mp3 file on the dashboard. I used what Bart attached, but it did not want to work. For the start, I am using a boolen inject (true), in the middle it looks like that:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/dbf23282ef537345b73b01552a83415ecfb0e574.png)

The play audio part is as Bart said, but when I click on the start button, the audio out says error.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [3 July 2020 20:02 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/19 "2020-07-03T20:02:44Z")

</div>

> [@tiby007](#):
>
> I want to play a mp3 file

Hey, can you please share your flow. I was not aware that youtube offers mp3 files...

---

<div class="post-metadata">

**Author:** ![tiby007](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tiby007](https://discourse.nodered.org/u/tiby007)\
**Post date:** [3 July 2020 20:47 UTC](https://discourse.nodered.org/t/playing-mp3-audio/8188/20 "2020-07-03T20:47:46Z")

</div>

I guess than this is the problem. I do not know what to write to the URL window in the htttp request node. How can I insert an MP3 to a htttps link?

I will share my flow as you requested:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/754588dabe67ab7a4a825c2d57b368bff64b6d66.png)

Best regards,  
Tibor

[Next page](https://discourse.nodered.org/t/playing-mp3-audio/8188.md?page=2)
