Play Sound Effects Through AppleScript
I'm looking for a way to play a sound (preferably the Glass sound effect, located in /System/Library/Sounds) in an AppleScript.
I'd like to do this as an audible way to tell that the script is done.
Is there a way to do this?
On the Web, I found info on scripting additions that make it easier, but I need this to be self-contained and self-reliant, so an extra utility won't work.
I was thinking that maybe, if need be, it could work something like this:
…
set PreviousDefault to (do shell script defauls read com.apple.systemsound …) --I don't know how to use the defaults read/write command, but I do know that this is where the name of the default sound effect is stored.
do shell script defaults write com.apple.systemsound … --Set the default to Glass.aiff
beep
do shell script defaults write com.apple.systemsound PreviousDefault
…
So, this would read the default sound effect and store it in a variable, set the default sound effect to Glass, beep (with glass), and reset the default sound effect to what it was before.
Would that work? I don't know how to use the defaults… commands.
Ideally, there would be an easier way to work this than what I came up with.
Thanks in advance!
-Nate
MacBook 2.4 ghz 4gb ram, Mac OS X (10.6.1), MacBook: June 2008, 2.4ghz Core 2 Duo, 4GB RAM. iPod Nano 3G. AirPort Extreme 20