Tony Stark
Tony Stark

Reputation: 25538

Best way to make this Apple Script play a specific portion of a song in iTunes?

I want iTunes to play a specific 60 seconds of every song in a playlist (say seconds 60-120). What's the applescript code to accomplish this? So far I have:

tell application "iTunes"
    repeat with i from 1 to count tracks of playlist "My Playlist"
        play track i of playlist "My Playlist"
    end repeat
end tell

Upvotes: 0

Views: 841

Answers (1)

adayzdone
adayzdone

Reputation: 11238

Try:

tell application "iTunes"
    set trackCount to count of tracks of playlist "My Playlist"
    repeat with i from 1 to trackCount
        play track i of playlist "My Playlist"
        set player position to 60
        repeat until player position ≥ 120
            delay 0.5
        end repeat
    end repeat
end tell

Upvotes: 1

Related Questions