PlaySound can't find file URL

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:

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:

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 :slight_smile:

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.

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

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.

2 Likes

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

2 Likes

Thank you very much guys :slight_smile:

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 :smiley:
Anything else obvious I'm missing?
I've tried a local dir like /home/alex and also a /svr/ dir.

Message hander call:

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

Gateway message script:

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

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

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

From the manual:

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?

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?

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

2 Likes
1 Like

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!