开发者

Objective-C Scripting Bridge and iTunes

开发者 https://www.devze.com 2023-02-11 00:47 出处:网络
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 wi

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号