While making a Photoshop plug-in, I had a question related to sound

Is it possible to create a function that executes the mp3 file in the plugin folder when the button is pressed?

Or you want to trigger a beep by creating a specific condition.

I used Audio for js or html and it didn’t work. Is this not supported?

if you’re talking about executing in an external player then this is possible with the right permissions and manifest version.

but playing audio inside the plugin itself as SFX is not supported AFAIK.

you can try webveiw for tutorials or important stuff but other than that it’s not currently (and may never be) supported

i saw someone request audio API in the XD forums with no official response yet

I opened the index.html file
The audio panel that was not visible appears, and when you press the play button, it starts playing.
But when I run it with the uxp builder, the audio doesn’t play.
new Audio(“path”) not working in js file
Is there any way to import an Audio-related class created externally?
Ah… This is a feature I really want to add. (weeping)

Did you read @Maher’s answer? It’s not supported in UXP. You can try Webview, but no guarantee it will work either.

BTW, would you mind sharing what the use case would be? I can’t think of a scenario where I would want Ps talking or playing to me :confused:

1 Like

unlike CEP… UXP does not use an actual web browser.

although it uses the same markup (HTML) it does not support every feature “actual” browsers do nor it should.

the sooner you accept this the less you’ll struggle with your work.

according to the official docs, we eventually will have to use only spectrum elements. so even expect a somewhat more restricted support in the future.

  • Prepare for the future - Spectrum UXP components will become the only supported user-interface controls in UXP in the future. Prepare now by using them instead of the HTML correlates.

more about unsupported elements

2 Likes

BTW, would you mind sharing what the use case would be? I can’t think of a scenario where I would want Ps talking or playing to me

In past years, I made a CEP plugin called Advanced Local Contrast Enhancer (ALCE). Alce turns out to be the Italian word for elk (the animal—it’s a word pun originated in a Dan Margulis’ class, but that’s not the point). As a prank, I used to play an elk call when users pressed the panel’s About button. Although elk’s calls don’t score very high as far as relaxing sounds are concerned, I’ve never had a single complaint about it in many years :clown_face:
+1 to UXP sound :blush:

4 Likes

OMG, I would’ve hated that so much :smiley: Unless I specifically press some button expecting for some sound to play, it’s a no go for me :slight_smile: If sound is unexpected, highest rating such app would get from me is 5/10 (everything else would only reduce the rating). I probably wouldn’t even rate it just because of that, but if there would be more issues, then that’s the starting point :smiley:

1 Like

I could listen to this for hours on end :rofl:

It reminds me my first attempts when, as a kid, I tried to play overtones with the tenor saxophone :melting_face:

3 Likes

Hahaha Did you really make that sound when you pressed the button?
It’s quite interesting, but if it’s really possible, I’d like to know how.

It wasn’t 1 minute long though, just a handful of seconds :wink:
I don’t remember how I did it, possibly it’s just one StackOverflow/MDN search away.

1 Like

Thank you. I’ll try to find one and study it!

Knowing how little experienced I was when I started, I doubt it was something fancier than this:

(reminder: it was CEP, that won’t work with UXP)

1 Like

haha Matches the code I was failing with earlier

I’ve plugged in an old backup, and to my surprise I can’t find the source code for the CEP version that I thought it contained the sound :thinking:
But I’ve found the Flash (CS5) version :rofl: and the elkCall.mp3

Flash hahaha It’s been a long time since I heard it.
I used to make a lot of games with flash as an exercise. (Could not be released :smiling_face_with_tear:)