On Mar 20, 2017, at 4:59 PM, ILJA SHEBALIN wrote:
My script wakes me up at the time prescribed by me by playing my selected tune.
instead of using Quicktime Player. For example the following handler repeatedly plays a
sound file until the process 'mainPID' is completed. (I have eliminated parts of the handler
on playUntilComplete(mainPID)
--
-- get soundAlias an alias to the sound file
--
--
--
set soundPath to (quoted form of (POSIX path of soundAlias))
set soundpid to do shell script "afplay " & soundPath & " &> /dev/null & echo $!" -- start the music
repeat
delay 1
try
do shell script "ps -p " & mainPID
if not (the result contains mainPID) then error
on error
exit repeat -- the process mainPID has finished
end try
try
do shell script "ps -p " & soundpid
on error
set soundpid to do shell script "afplay " & soundPath & " &> /dev/null & echo $!" -- restart the music (loop)
end try
end repeat
try
do shell script "kill " & soundpid -- kill the music
end try
end playUntilComplete -------------------------------