|
| [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! global MyVol global MyFadeRate global MyEndTime global MyDelay global NewShow 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 delay MyDelay repeat while NewShow is false delay MyFadeRate get NewShow if NewShow is false then tell application "iTunes" get the sound volume if result > 0 then set the sound volume to the result - 1 else set Mymessage to (get current date) do shell script "say " & Mymessage tell application "Finder" activate display dialog Mymessage as text end tell exit repeat end if end tell else exit repeat end if end repeat end if 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) delay 0.1 end repeat set the sound volume to 100 play playlist "Music" end tell end if end timeout end run 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? Thanks again! Joshua Joshua Whalen +1-212-931-9812 - home, voicemail +1-747-665-1905 - SIP "Vision without action is a day dream, Action without vision is a nightmare." -- Japanese proverb |
_______________________________________________ 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
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.