Objective-C Scripting Bridge and iTunes

1k views Asked by At

Hi i need a little help i want to include 2 buttons on my Mac App which will trigger 2 actions, 1 will trigger the iTunes shuffle feature and set it to YES but if it is all ready set to YES then it will set it to NO. The other will get iTunes current playback repeat mode.

This is what i have found from the iTunes.h file and also here's a description of the iTunes.h file http://merbist.com/2010/01/17/controlling-itunes-with-macruby/

@property BOOL shuffle;  // play the songs in this playlist in random order?
@property iTunesERpt songRepeat;  // playback repeat mode

Can anyone help me, thanks Sami.

1

There are 1 answers

0
Philippe On BEST ANSWER

You need to declare an instance of SBApplication to talk to iTunes:

SBApplication *_iTunes = [[SBApplication applicationWithBundleIdentifier: @"com.apple.itunes"] retain];

Once you have this SBApplication (keep it around in your class), use it to control iTunes directly. For example, to turn on the "Shuffle" mode:

_iTunes.currentPlaylist.shuffle = YES;

will do the trick.