Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Playing audio files with applescript

I have used the following script in Snow Leopard, but it doesn't seem to work with Mountail Lion. Suggestions?


tell application "QuickTime Player"

activate

set the_file to "VGSMLShawver:Macintosh HD:Library:Audio:Apple Loops:Apple:iLife Sound Effects:Stingers:Comedy High Honk.caf"

set file_path to quoted form of (POSIX path of (the_file as alias))

do shell script ("afplay & file_path & file_path & " > /dev/null 2>&1&")

end tell

AppleScript

Posted on Jan 11, 2013 5:03 PM

Reply
3 replies

Jan 11, 2013 6:43 PM in response to lshawver

I think your script got mangled when you copied it over - the shell script uses file_path twice and there is a quoting issue. I'm not sure what else you are doing that requires the sound to play in the background, but you don't need QuickTime Player at all for this (afplay will play the audio file by itself), for example:


setfile_pathtoquoted formofPOSIX pathof (choose file)

do shell script"afplay " & file_path & " > /dev/null 2>&1 &"

Playing audio files with applescript

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