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 04:31 PM

Reply

Similar questions

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

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.

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.