Play a "hidden" sound every 30 minutes?

Hello,
I know this is a lame request, I won’t even go into details [boring internal thing for our studio], but I’m looking for a way to automatically play a sound clip (short, 5 second .wav file [or other format, doesn’t matter]) without any user interaction (or other indication on how this sound file is playing), every 30 minutes. Ideally, this sound file would be “embedded” somehow with the AppleScript so it’s easy to deploy to all production machines in the studio.
If anyone could lend me a hand, it’d be appreciated!
Thanks,
Kristin.

Have a look at PlaySound

An example of how I use it is in the script below by Nigel Garvey which runs as a background stay-open on idle script. You’d have to adjust it for half-hours, of course.

on idle
	local h
	
	tell (time of (current date))
		set h to ((it div hours + 11) mod 12) + 1
		tell (it mod hours)
			if (it < 10) then
				-- If it's now less than ten seconds after an hour, chime.
				my chime(h)
			else if (it < 300) then
				-- Otherwise, if it's within the first five minutes, make a belated announcement.
				my waffle(h)
			end if
		end tell
		
		-- Idle until the next five-minute boundary.
		return (86399 - it) mod 300 + 1 -- ie. (days - (time of (current date)) - 1) mod (5 * minutes) + 1
	end tell
end idle

to chime(h)
	tell application "Play Sound"
		play (("" & (path to "dlib" from system domain) & "Sounds:" & "Glass.aiff") as alias) repeat (h - 1)
		quit
	end tell
end chime

on waffle(h)
	say "Oops! It's a little past " & h & " o'clock."
end waffle

The direct link for Play Sound is: http://microcosmsoftware.com/playsound/

There’s also a command line tool by that name: http://www.steike.com/code/playsound/

There’s also a unix executable at Hieper Software called Play which will play anything QuickTime can play. {aiff, aifc, wav, mp3, ulw, au, snd, mid, m4a, m4p} (Play has to be made executable after download - chmod +x).

e.g.

-- NOTE: press the escape key to quit a song in progress
set PM to POSIX path of (path to music folder)
do shell script "Posix/Path/To/Play " & PM & "GDead/'1.08 Me & My Uncle.mp3'"

With PlaySound installed, there’s also a solution without AppleScript,
using a launchd agent or a crontab entry, just with this line as “executable”

open -a Play\ Sound /path/to/Sound.aiff

Hi Stefan,

do you also know how to close/stop the file via Commandline?


do shell script "open -a 'Play Sound.app' /Users/sl/Desktop/Nelly.mp3"

plays the file - but how to stop it?

thanks for your reply.

Stefan

the “brutal” way:

do shell script "killall 'Play Sound'"

Play Sound also responds to the escape key. Pressing escape will stop it.