# PlaySound can't find file URL

**URL:** <https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324>\
**Category:** Ignition\
**Tags:** perspective, maker\
**Created:** [December 30, 2024, 9:35pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324 "2024-12-30T21:35:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [December 30, 2024, 9:35pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/1 "2024-12-30T21:35:42Z")

</div>

Hi Crew,

Trying to setup something silly for New Years Eve, and I've hit an error I can't seem to process.  
Gateway is running on a ubuntu machine.  
I'd like to play a sound from the gateway on an event from a perspetive session.  
The code I'm using is:

```python
system.util.playSoundClip("\srv\ignition\Audio\MySound.wav", 1.0, 0)

```

My understanding is this should play a sound on the gateway, however I'm getting error:

```python
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ValueError: Unable to open file/url: \srv\ignition\Audio\MySound.wav

```

I've tried all sorts and cant fathom it out - What am i missing 🙂

Thanks!

Edit: Running that code in the script console to try and make it work before integrating into the event  
Edit2: The files are on the gateway in that location.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 30, 2024, 9:47pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/2 "2024-12-30T21:47:13Z")

</div>

> [@Alex\_Leech](#):
>
> Running that code in the script console to try and make it work before integrating into the event

The script console runs on the local machine. It won't find the file if it's on a separate gateway machine.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 30, 2024, 9:51pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/3 "2024-12-30T21:51:15Z")

</div>

Building on what Transistor mentioned, if you want to test this from the designer, you'll need to configure a gateway message handler that has the `playAudioClip` call in it, and call that handler via `system.util.sendMessage` in your script console.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 30, 2024, 9:57pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/4 "2024-12-30T21:57:11Z")

</div>

> [@Alex\_Leech](#):
>
> `system.util.playSoundClip("\srv\ignition\Audio\MySound.wav", 1.0, 0)`

In addition to what others have said, use forward slashes.

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [December 30, 2024, 10:31pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/5 "2024-12-30T22:31:52Z")

</div>

Thank you very much guys 🙂

I've changed to a gateway script, and seem to have removed the errors as I see both the 'Trying' and 'Done' in the below script... But no errors and also no sound 😃  
Anything else obvious I'm missing?  
I've tried a local dir like /home/alex and also a /svr/ dir.

Message hander call:

```python
system.util.sendMessage('nye-24', 'playSound',params={},scope='G')

```

Gateway message script:

```python
logger = system.util.getLogger("testlogger")
logger.info("Trying")
system.util.playSoundClip("/home/alex/Music/NYE/Andy.wav",1.0,1)
logger.info("Done")

```

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 30, 2024, 10:34pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/6 "2024-12-30T22:34:21Z")

</div>

Does your gateway device have speakers and are they enabled/unmuted?

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [December 30, 2024, 10:34pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/7 "2024-12-30T22:34:45Z")

</div>

It does - I can play the wav file by clicking it through VLC 🙂

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 30, 2024, 10:35pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/8 "2024-12-30T22:35:58Z")

</div>

From the [manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-playSoundClip#a-word-on-scope):

> When calling this function from the Gateway scope, the sound will not play unless the operating system has been configured to allow services to play sounds (an uncommon scenario).

Has the Ignition service been configured to allow it to play sounds?

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [December 30, 2024, 10:48pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/9 "2024-12-30T22:48:19Z")

</div>

I'm looking onlne and not really finding what I need to do to enable sounds?  
Perhaps I could solve it by calling a separate command line audio player?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 30, 2024, 11:03pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/10 "2024-12-30T23:03:23Z")

</div>

Generally the service user need to be a member of the `audio` group. (Varies by distro...)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 30, 2024, 11:07pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/11 "2024-12-30T23:07:49Z")

</div>

> <https://askubuntu.com/questions/79565/how-to-add-existing-user-to-an-existing-group>

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [December 30, 2024, 11:22pm UTC](https://forum.inductiveautomation.com/t/playsound-cant-find-file-url/100324/12 "2024-12-30T23:22:24Z")

</div>

Thanks chaps!  
I've checked out the service and its running as my user already with the audio group.  
I seem to recall last year I had to make a python OPC server that listened for ignition to write tags and then played sound / midi notes from there. Was hoping to avoid that, but guess it'll be time to dust the script off!  
Ill have another crack in the morning.  
Thanks for all the help, I'll report back with the final solution when I get there!
