playing sound files with applescript in snow leopard

My old reliable, "Play Sound," apparently doesn't work with 10.6.3 (or 10.6.x in general). Can you suggest a simple alternative?

Example:

tell application "?"
 play file ((path to desktop as Unicode text) & "Sound Files:doorbell.wav")
 
end tell


Message was edited by: osimp

Message was edited by: osimp

Intel Mac Pro, Mac OS X (10.6.3)

Posted on Apr 21, 2010 2:38 PM

Reply
Question marked as ⚠️ Top-ranking reply

Posted on Apr 21, 2010 3:00 PM

afplay comes installed on Snow Leopard

/usr/bin/afplay
4 replies
Sort By: 

Apr 21, 2010 3:08 PM in response to osimp

Some time ago I wrote a CGI-Script, that I could trigger through a simple WEB-Request. This CGI-Script was just some AppleScript (through oasascript-command) to set up the server's sound-volume and for playing a sound through the command line-app.
I used a small example-app Apple greated (X-Code command line app-example) which is called Ascii-movie-player.
When you open a quicktime-movie using this app in your terminal, it trys showing it using ascii-characters, but it works with simple soundfiles (quicktime is able to play), too.

I compiled it for PPC so it should work, when Rosetta ist installed. For more info take a look at
http://hubionmac.com/wordpress/2008/10/alarm-ton-bei-aufruf-einer-website-panic- button-20/
There you will find a copy of the source and a compiled version (CGI-Alarm)

e.g. you saved the player binary at /usr/local/bin/player
do shell script "/usr/local/bin/player ~/Music/doorbell.wav"

should work
Reply

Apr 21, 2010 3:34 PM in response to osimp

Hi

give this a shot using afplay



-----
set the_file to "Macintosh HD:Users:osimp:Desktop:Samashing Pumpkins.aif" --path to your sound file
set file_path to quoted form of (POSIX path of (the_file as alias))
do shell script ("afplay " & file_path & " > /dev/null 2>&1 &")
-----
Reply

Apr 22, 2010 7:41 AM in response to Budgie

That works, so credit where credit is due.

Although I can definitely incorporate that in an AppleScript, it's a bit clumsy to do when there are a lot of sound files/scripts. I was really hoping for a third-party application that I could simply drop in, in place of "Play Sound."
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

playing sound files with applescript in snow leopard

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.