|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
This routine controls a fade-out timer for itunes. It works nicely most of the time, but on slower machines, accumulated latency will cause it to run a second or two too long, with catastrophic results: The new playlist starts, sets the volume to 100, and the fader never reaches zero, thus causing the playlist to fadeout on launch. Not good.
To compensate for this, I added a variable and a check for the variable's status. The playlist sets NewShow to true on launch, and the fader sets it to false, and then checks on each loop to see if it's true or false. If it's true, it should quit the loop. There's just one problem: It doesn't.
I have tried setting it as a property that defaults to false, I have tried setting it as a property that defaults to true. I have tried putting the check in different parts of the loop, I have tried putting multiple checks all through the loop, I have tried all kinds of variations, it never gets the variable status.
I have to admit, that this is the first time I've tried using a variable that is not contained in the loop itself (as for example, the >0 check) so maybe this just isn't doable. But it's the very last issue with the actual functionality of this program, and when this is solved, the program is done. I know I've been asking a lot of questions lately, but I saved the tough stuff for last, so it all backed up. Sorry to hog everyone's time. I'll see if I can hang out and make some paybacks once this is done!
on run argv
with timeout of 99999 seconds
if item 1 of argv = "5.19.088.11.44.AM" then
set MyFadeRate to 0.6
set MyDelay to item 2 of argv
set NewShow to false
repeat while NewShow is false
if NewShow is false then
tell application "iTunes"
get the sound volume
if result > 0 then
set the sound volume to the result - 1
set Mymessage to (get current date)
do shell script "say " & Mymessage
tell application "Finder"
display dialog Mymessage as text
if item 1 of argv = "Music" then
set NewShow to true
tell application "iTunes"
set MyVol to 1
repeat 10 times
set the sound volume to (MyVol + 10)
set the sound volume to 100
play playlist "Music"
The crontab that calls it looks like this:
11 8 19 5 * osascript ~/Library/Caches/RadioKnife/blade.scpt "5.19.088.11.44.AM" 52
12 8 19 5 * osascript ~/Library/Caches/RadioKnife/blade.scpt "Music"
The fader is called a minute early with a 52 second delay, thus producing an 8-second long fade-out. The playlist is called at the (presumed!)
end of the fadeout When the fader quits like it's supposed to it works beautifully. On fast hardware, everything runs great! It's on the old stuff
it has problems, so I'd like to have this fail-safe device. Even on fast hardware, heavy loads or other unforeseeable events could cause the script
to run a second or two off. This just makes sure that doesn't cause a disaster.
BTW, back in the stone age (the '90's) it was conventional wisdom that applescript had a latency of .25 second per event. I'm wondering if
that's still so, and if not, is the propagation of an apple event a variable or a constant?
_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Studio mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.