• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
no exit!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

no exit!


  • Subject: no exit!
  • From: Joshua Whalen <email@hidden>
  • Date: Tue, 3 Jun 2008 18:14:34 -0400

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've posted this on the Applescript Studio, with no responses, possibly it was a busy day, or possibly it wasn't relevant, since it is not, itself, an applescript studio issue, but rather a script generated on the fly by applescript studio. That list has been otherwise excellent on numerous other issues, alas, just not this one.

That having been said, I sincerely plead for assistance. I am so close to done with this project, which has dragged on forever, and this is one of the last glitches needing to be ironed out before I can sell this and pay my rent.

Help, please?


(* this script is generated by an 
AppleScript Studio application 
and then called by the unix cron daemon. *)

global MyVol
global MyFadeRate
global MyEndTime
global MyDelay
global NewShow
on run argv
with timeout of 99999 seconds

(* this routine is called to 
start a new itunes playlist playing.
It sets the variable "NewShow" to true before
doing anything else.*)

if item 1 of argv = "music for evenings" 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 for evenings"
end tell
end if

(* this routine is called by cron when it's time 
end the preceeding show. It sets new show to false, 
and then proceeds to lower the volume at a pre-set rate
until the volume reaches 0 or the variable "NewShow" becomes
false. At least, that's what it's supposed to do, except it
doesn't, which on slower machines can cause the NEXT playlist
to immediatly fade to silence on launch, because launching the
nest playlist also sets the volume to 100, thus preventing the
fader from ever reaching 0. *)

if item 1 of argv = "6.3.087.35.40.PM" then
set MyFadeRate to 0.1
set MyDelay to item 2 of argv
set NewShow to false
delay MyDelay
repeat while NewShow is false
delay MyFadeRate
get NewShow
tell me
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
exit repeat
end if
end tell
else
if NewShow is true then
exit repeat
end if
end if
end tell
end repeat
end if

(* this routine is called to 
start a new itunes playlist playing.
It sets the variable "NewShow" to true before
doing anything else.*)

if item 1 of argv = "Fun" 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 "Fun"
end tell
end if


(* this routine is called by cron when it's time 
end the preceeding show. It sets new show to false, 
and then proceeds to lower the volume at a pre-set rate
until the volume reaches 0 or the variable "NewShow" becomes
false. At least, that's what it's supposed to do, except it
doesn't, which on slower machines can cause the NEXT playlist
to immediatly fade to silence on launch, because launching the
nest playlist also sets the volume to 100, thus preventing the
fader from ever reaching 0. *)


if item 1 of argv = "6.3.088.29.44.PM" then
set MyFadeRate to 0.08
set MyDelay to item 2 of argv
set NewShow to false
delay MyDelay
repeat while NewShow is false
delay MyFadeRate
get NewShow
tell me
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
exit repeat
end if
end tell
else
if NewShow is true then
exit repeat
end if
end if
end tell
end repeat
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.

Thanks again!

Joshua

Joshua Whalen
email@hidden
email@hidden
http://www.panix.com/~joshua/resume.html

"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-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: no exit!
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: Script for Auto-login to websites
  • Next by Date: Newbie question...
  • Previous by thread: Re: Targetting a specific Word version
  • Next by thread: Re: no exit!
  • Index(es):
    • Date
    • Thread