# Playing MP3 file using Exec node/mpg321, getting an error

**URL:** https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068
**Category:** General
**Created:** [17 May 2024 16:34 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068 "2024-05-17T16:34:39Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [17 May 2024 16:34 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/1 "2024-05-17T16:34:39Z")

</div>

I'm able to play sound files from the command line, but get an error 1 from the exec node.

"High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3.  
Version 0.3.2-1 (2012/03/25). Written and copyrights by Joe Drew,  
now maintained by Nanakos Chrysostomos and others.  
Uses code from various people. See 'README' for more!  
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!  
tcgetattr(): Inappropriate ioctl for device

Directory: /home/pi/Music  
Playing MPEG stream from test-of-mpg321\_Joanna-standard.mp3 ...  
MPEG 2.0 layer III, 48 kbit/s, 22050 Hz mono  
Can't find a suitable libao driver. (Is device in use?)"

---

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [20 May 2024 13:46 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/2 "2024-05-20T13:46:22Z")

</div>

Turns out, it works fine until I set up node-red as a service, and then the error starts happening.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 May 2024 14:33 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/3 "2024-05-20T14:33:10Z")

</div>

That will be because the environment in which the service runs is different to the environment when a user is logged on. Possibly a PATH issue or permissions. I don't know enough the subject to say what it might be in this case.

Is the service being run as the same user as when you run it from the command line?

If you login using ssh and try to run from the command line then, does it work?

---

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [20 May 2024 19:00 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/4 "2024-05-20T19:00:40Z")

</div>

It works fine at all times if I run from the command line, when I use node-red-pi to start node-red it still works, If I use "sudo systemctl enable nodered.service" then I'm done, it no longer works even if I use "sudo systemctl disable nodered.service" to stop it.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 May 2024 19:52 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/5 "2024-05-20T19:52:29Z")

</div>

> [@Buzzylogic](#):
>
> It works fine at all times if I run from the command line

Including when the command line is in an ssh terminal?

---

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [20 May 2024 19:58 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/6 "2024-05-20T19:58:14Z")

</div>

yes, It always works fine when I ssh in.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 May 2024 20:15 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/7 "2024-05-20T20:15:20Z")

</div>

OK, in that case, as I said

> [@Colin](#):
>
> That will be because the environment in which the service runs is different to the environment when a user is logged on. Possibly a PATH issue or permissions.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 May 2024 20:17 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/8 "2024-05-20T20:17:00Z")

</div>

> [@Buzzylogic](#):
>
> even if I use "sudo systemctl disable nodered.service" to stop it.

That does not stop the service, it just tells it not to run on boot. `node-red-stop` or  
`sudo systemctl stop nodered` will stop it.

---

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [20 May 2024 21:04 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/9 "2024-05-20T21:04:27Z")

</div>

Just saying that once I set it up as a service, mgp321 no longer works, even if I reboot the pi and restart Node-Red manually (after disabling the nodered.service).

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [20 May 2024 22:44 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/10 "2024-05-20T22:44:55Z")

</div>

I use `omxplayer` and it works.

Just saying if you are still having problems and are open to alternatives.

---

<div class="post-metadata">

### Author: ![Buzzylogic](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Buzzylogic](https://discourse.nodered.org/u/Buzzylogic)
#### Post date: [21 May 2024 02:27 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/11 "2024-05-21T02:27:33Z")

</div>

I got that to work, sorta, it was cutting off the end of the MP3, I'm using this for announcements in a manufacturing setting, it cuts off the last word or two more often than not. I did get MPG321 to work, I just have to manually start Node-Red after reboots.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [22 May 2024 06:30 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/12 "2024-05-22T06:30:24Z")

</div>

> [@Buzzylogic](#):
>
> I just have to manually start Node-Red after reboots.

That is not good.

You do know the way to make Node-Red auto start?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [22 May 2024 09:45 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/13 "2024-05-22T09:45:43Z")

</div>

> [@Trying\_to\_learn](#):
>
> You do know the way to make Node-Red auto start?

The whole point of this thread is that if node-red is started as a service then it does not work.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [22 May 2024 09:47 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/14 "2024-05-22T09:47:01Z")

</div>

Oh. Sorry.

Just all the posts/replies seem to be concentrating on the music part and not the auto start part.

---

<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: [20 August 2024 09:47 UTC](https://discourse.nodered.org/t/playing-mp3-file-using-exec-node-mpg321-getting-an-error/88068/15 "2024-08-20T09:47:41Z")

</div>

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