Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set iTunes 11 in shuffle or repeat mode via applescript

According to http://dougscripts.com/ setting shuffle and repeat modes via applescript is broken in iTunes 11.

According to this stackoverflow answer shuffle is now a playlist independent setting.

Thus, I tried to set the shuffle value via the UI, either by the LCD-ish display of iTunes or via the menu bar. All I could get was "unknown UI index" errors when trying to click the shuffle button/menu item, either in the LCD area or the menu bar. (I'm new to applescript).

If some of you could come up with a way to toggle shuffle mode on iTunes 11, that would be great. Also I'd prefer a solution based on the menu bar rather than the LCD display since the shuffle button is not always visible in the latter.

Ideally, I'd prefer a semantic-based solution over a UI-based solution but I'm not sure if it's possible (iTunes 11 applescript library seems to be outdate since it mention a "shuffle" property for "playlists" items).

like image 309
user113101 Avatar asked Feb 03 '13 16:02

user113101


1 Answers

For the new Music app, this works. If you're using iTunes still, change "Music" to "iTunes".

Repeat can be set to one or off or all.

tell application "Music"
   set song repeat to off
end

Shuffle can be set to true or false.

tell application "Music"
   set shuffle enabled to true
end

You can find more details at Dougscripts.

like image 134
ace973 Avatar answered Jan 03 '23 21:01

ace973