Re: Play sounds via script
Re: Play sounds via script
- Subject: Re: Play sounds via script
- From: Luther Fuller <email@hidden>
- Date: Sun, 03 Mar 2013 12:20:20 -0600
Slightly on another topic, but ... I was curious if I could play an audio file so that:1. The application quit when the sound was finished; and 2. If the application quit, then the sound is killed.
I had to use a global to do this. (I don't usually use globals.) I had to learn behavior of idle and quit handlers that I didn't know. Here's the final script ...
on run global soundpid choose file with prompt "Choose an audio file ..." of type "public.audio" -- Cancel Quits here set fileAlias to the result (quoted form of (POSIX path of fileAlias)) set soundpid to do shell script "afplay " & the result & " &> /dev/null & echo $!" end run
on idle global soundpid try do shell script "ps -p " & soundpid on error quit end try return 1 end idle
on quit global soundpid try do shell script "ps -p " & soundpid do shell script "kill " & soundpid end try continue quit end quit
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden