Super Amazing iTunes Controller Project

1 post / 0 new
Tiger G5 Kid's picture
Offline
Last seen: 18 years 1 month ago
Joined: Dec 20 2003 - 10:38
Posts: 134
Super Amazing iTunes Controller Project

I'm working on a new program that connects to iTunes via applescript and contols it with lots of preset commands. One part bogs it down really slow though -

on clicked theObject
tell application "iTunes"
pause
previous track
end tell
repeat
tell application "iTunes"
set startoftrack to (get start of current track)
set playerposition to (get player position)
set lengthasd to (get duration of current track)
end tell
if (startoftrack is playerposition) then
try
tell application "iTunes"
set TrackName to the name of current track
set TrackAlbum to album of current track
set TrackArtist to artist of current track
set TrackRating to rating of current track as integer
end tell
on error
beep
say "Please start a track in iTunes"
end try
tell window of theObject
set the contents of text field "namebar" to TrackName
set the contents of text field "artistbar" to TrackArtist
set the contents of text field "albumbar" to TrackAlbum
set the contents of text field "toptext" to "Connected..."
if myTrackRating is 100 then
set image of image view "ratings" to load image "100"
else if myTrackRating is 80 then
set image of image view "ratings" to load image "80"
else if myTrackRating is 60 then
set image of image view "ratings" to load image "60"
else if myTrackRating is 40 then
set image of image view "ratings" to load image "40"
else if myTrackRating is 20 then
set image of image view "ratings" to load image "20"
end if
end tell

end if
end repeat
end clicked

If I set that to a on opened command, it doesn't work and comes up with an error (ending with (10)). Otherwise, it really slows down the program. Really. A lot. Any suggestions?
All I'm really looking for is a way to grab track information when a track changes and put that information in text boxes. All of the buttons (play, pause, next, search...) are in other scripts.