Eric
Eric

Reputation: 3257

Play iTunes Continously

I have an applescript that plays a specific iTunes playlist.

tell application "iTunes"
  play user playlist myPlaylist
end tell

But this will only play the play list once, then it stops. What I want is for the playlist to reload, then play continuously 24/7 until someone actually stop or pause the iTunes.

I tried to modify the code to this, but it doesn't work.

on idle
  tell application "iTunes"
    play user playlist myPlaylist
  end tell
end idle

The on idle code actually does nothing, even after iTunes stops.

I also try to reload the user playlist, but also doesn't work.

tell application "iTunes"
    repeat until player state is stopped
        play user playlist myPlaylist
    end repeat
end tell

Thank you.

Upvotes: 0

Views: 906

Answers (2)

Eric
Eric

Reputation: 3257

The code for repeating playlist does not work on iTunes 11. The link regulusy6633 posted contains the answer. The code below works for iTunes 11.

    tell application "System Events" to tell process "iTunes"'s menu bar 1's menu bar item "Controls"'s menu 1's menu item "Repeat"'s menu 1
        perform action "AXPress" of menu item "All"
    end tell

Upvotes: 0

regulus6633
regulus6633

Reputation: 19040

If you look in iTune's applescript dictionary at the "playlist" class you will see it has a command called "song repeat". Maybe that will help you.

tell application "iTunes"
    tell user playlist myPlaylist
        set song repeat to all
        play
    end tell
end tell

EDIT: As of itunes version 11 the above code no longer works. See this question for solutions. I posted an answer there.

Upvotes: 1

Related Questions