I’m trying to write a script that plays a track for 60 seconds, waits for the track to finish playing, and then do the same for the next track. In order to wait for the track to finish playing, I want to poll ‘player state’ as such
repeat while player state is playing
-- Do nothing
end repeat
But when I run the script, I get an error, saying “No result was returned from some part of this expression.” and the word “playing” is highlighted. Any idea of what’s going on?
I’m running iTunes 3.0.1 and Mac OS X 10.1.5
Also, below is the whole script just in case it helps. Don’t mind the commented out sections. Those aren’t enabled for debugging purposes. Thanks a lot!
Mike T.
tell application "iTunes"
activate
tell the current playlist
set shuffle to false
set shuffle to true
--repeat with i from 1 to 10
set i to 1
set randomStartTime to random number ((duration of track i) - 60)
set start of track i to 0
set finish of track i to (duration of track i) - 1
set start of track i to randomStartTime
set finish of track i to (start of track i) + 60
play track i
repeat while player state is playing
-- do nothing
end repeat
end tell
end tell