iTunes hangs when AppleScript is used
Hi!
I have a small problem: I use the following script to rate a track and set the "modified" date to today:
on ratethetrack(keyCode)
try
tell application "iTunes"
set tempvar to composer of current track
set composer of current track to "*"
set temprate to keyCode * 20
if temprate > 100 then set temprate to 0
set rating of current track to temprate
set composer of current track to tempvar
end tell
on error
beep
end try
end ratethetrack
The keycode is from "1" to "5". All works very well, but sometimes itunes hangs (that means the music stops for up to two seconds) when I activate this routine.
My question: Is there any way to ckeck wether iTunes is very busy and then postpone the script? Or is there a better way that doesnt use as much of iTunes' resources?
THX!
ALEXander.
[1169 byte] By [
wackazong] at [2007-11-9 13:51:36]

# 1 Re: iTunes hangs when AppleScript is used
I can't imagine why this routine would cause iTunes to stop playing for any length of time. These are not processor intensive commands.
There's no way to check the "busy-ness" of iTunes. Since you are using current track, that implies that iTunes is either playing or paused. You could check for player state (stopped/paused/playing/fast forwarding/rewinding) but since you want current track, only paused and playing would be necessary.
What else is going on when you run the script?
# 2 Re: iTunes hangs when AppleScript is used
Yeah, I find it strange as well, but nothing much is going on elsewhere. I am using this script with Salling Clicker, but it is the only command where iTunes hangs. I have the intuition that it is because of the modification date manipulation trick. Reading and writing the composer three times very fast in a row is maybe too much. iTunes is always playing when I use the script, so that cannot be the problem either.
Dazzled and confused,
ALEXander.