• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Can you play a sound using a script in Photoshop?

Enthusiast ,
Oct 18, 2014 Oct 18, 2014

Copy link to clipboard

Copied

I'd like to play an audio alert once my script finishes running, I looked up some options online, but I can only find reference to how to play sound using javascript and html5.

TOPICS
Actions and scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Mar 26, 2024 Mar 26, 2024

Solution on Mac:

try{
app.system("afplay /System/Library/Sounds/Glass.aiff")
}catch(e){
};

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 18, 2014 Oct 18, 2014

Copy link to clipboard

Copied

beep();

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 18, 2014 Oct 18, 2014

Copy link to clipboard

Copied

Thanks, but I'm looking to play a sound from a file rather than just the default error noise, any pointers?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 19, 2014 Oct 19, 2014

Copy link to clipboard

Copied

You could play a music file, as an example.

var music = new File("/E/Music/Country/Sundown.mp3");

if(music.exists) music.execute();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2014 Oct 19, 2014

Copy link to clipboard

Copied

Then you should have asked how to play a sound file rather then play and alert.

try{

   var Sound = new File("C:/Windows/Media/tada.wav");

    Sound.execute();

}catch(e){

alert("Can Not Play Sound");

};

This depends on system file associations. If there is a player associated with the file extension it should open and play the sound. It may also remain open after the sound is over, or may loop playing the sound repeatly

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 19, 2014 Oct 19, 2014

Copy link to clipboard

Copied

Awesome! This is definitely more of the idea, although it opens up windows media player, to play. It would be used in a batch, so I wouldn't necessarily want to have to open a program every time, but it does make sense as I'm unaware if there's a default background player for PC and mac. Otherwise I did find documentation on flash, and in using Window, and adding flash player to it, I'm able to get the desired sound to play. However I tried using a relative path from the script to the swf, and it came back with an error. I had to place the swf on my desktop to test correctly. Is there a way to use relative paths?

  win.preview = win.add ('flashplayer',undefined,'~/Desktop/test.swf');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2014 Oct 19, 2014

Copy link to clipboard

Copied

You need the full path if it relative to the script you can get the scripts path

alert(File($.fileName).parent.fsName);

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

I tried adding this to the end of the following script, but no sound plays after it finishes. Am I missing something?

for (var i = 0; i < 2; i++) app.doAction("Pixel Crop+Scale Loop","shape");beep();

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

It works for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Yeah, it's working for me now too.  I thnk there was an issue w/ my system sound when I tried it before as I have since rebooted and now get the system alert sound at the end of the script, which is what I assume is supposed to happen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

LATEST

Solution on Mac:

try{
app.system("afplay /System/Library/Sounds/Glass.aiff")
}catch(e){
};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines