You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Simple AppleScript working with QuickTime (sound files)

I am trying to write a simple script to open and play a sound file (.mp3 format). It works fine outside the script, simply opening the file in Finder using the QuickTime Player app seems perfectly compatible (plays the sound).


This fails, why?


tell application "QuickTime Player"

set sndAlarm to open POSIX file "~/Library/Sounds/Alarm.mp3"

play sndAlarm

end tell


MacBook Air 15″, macOS 15.1

Posted on Nov 6, 2024 4:31 PM

Reply
2 replies

Nov 9, 2024 11:42 PM in response to smrc8081

Only worked for me when not using POSIX, with either script. With POSIX, it errored out 🤷‍♂️. [macOS 14.7.1]


tell application "QuickTime Player"
	set sndAlarm to open file "Macintosh HD:Users:jappleseed:Library:Sounds:Alarm.mp3"
	play sndAlarm
end tell



tell application "QuickTime Player"
	activate
	open file "Macintosh HD:Users:jappleseed:Library:Audio:Sounds:Alerts:alarm.caf"
	set sndAlarm to first document
	play sndAlarm
end tell

Simple AppleScript working with QuickTime (sound files)

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