hbquikcomjamesl
Registered
I have a "startup sound" script on my Mac, that plays any one of a rotating series of .wav files, exactly once, when I sign on to my Mac. When I got started on this, I quickly found out that if I allow iTunes to play a sound file, it immediately imports it into the playlist (NOT desired behavior), and then immediately runs through the playlist (a behavior I find profoundly undesirable, regardless of the circumstances). So I found that QuickTime would at least playback a sound file exactly once, although it wouldn't exit immediately after doing so.
I came up with the following, which has the problem that QuickTime doesn't reliably exit. I've also come up with something similar, to play a specific sound to alert me to, for example, dental appointments, so that I can shut down and leave in time, but it doesn't even reliably play the sound.
The ideal solution would be something completely headless, that doesn't have to be told to exit after playing the sound file.
--
JHHL
I came up with the following, which has the problem that QuickTime doesn't reliably exit. I've also come up with something similar, to play a specific sound to alert me to, for example, dental appointments, so that I can shut down and leave in time, but it doesn't even reliably play the sound.
Code:
property cycle : 0
set cycle to cycle + 1
if cycle > 7 then set cycle to 1
if cycle = 1 then
playback("/Users/jamesl/Library/Sounds/halcircuits.wav")
else if cycle = 2 then
playback("/Users/jamesl/Library/Sounds/helpyou.wav")
else if cycle = 3 then
playback("/Users/jamesl/Library/Sounds/homcomp.wav")
else if cycle = 4 then
playback("/Users/jamesl/Library/Sounds/parental.wav")
else if cycle = 5 then
playback("/Users/jamesl/Library/Sounds/goodmorn.wav")
else if cycle = 6 then
playback("/Users/jamesl/Library/Sounds/wlcomjp.wav")
else if cycle = 7 then
playback("/Users/jamesl/Library/Sounds/eglanded.wav")
end if
to playback(aSound)
tell application "QuickTime Player"
activate
try
set frontDoc to front document
close front document
on error err number errNum
if errNum is -1719 then
-- There is no open document
else if errNum is -10000 then
-- Front doc exists, but does not really...
else
log err
end if
end try
open aSound
play front document
-- Hide QTP
tell application "System Events"
keystroke "h" using command down
end tell
delay 8
quit
end tell
end playback
The ideal solution would be something completely headless, that doesn't have to be told to exit after playing the sound file.
--
JHHL