+ return [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool: YES], @"Remote",
+ [NSNumber numberWithBool: YES], @"Basic Track Control",
+ [NSNumber numberWithBool: YES], @"Track Information",
+ [NSNumber numberWithBool: YES], @"Track Navigation",
+ [NSNumber numberWithBool: YES], @"Upcoming Songs",
+ [NSNumber numberWithBool: YES], @"Playlists",
+ [NSNumber numberWithBool: YES], @"Volume",
+ [NSNumber numberWithBool: YES], @"Shuffle",
+ [NSNumber numberWithBool: YES], @"Repeat Modes",
+ [NSNumber numberWithBool: YES], @"Equalizer",
+ [NSNumber numberWithBool: YES], @"Track Rating",
+ nil];
+}
+
+- (BOOL)showPrimaryInterface
+{
+ // Make this into AppleEvents... shouldn't be too hard, I'm just too tired to do it right now.
+ //tell application "iTunes"
+ // set frontmost to true
+ // set visible of browser window 1 to true
+ // set minimized of browser window 1 to false
+ // set view of browser window 1 to (playlist (index of current playlist))
+ //end tell
+ //Someone do this plz kthx
+ return NO;
+}
+
+- (ITMTRemotePlayerRunningState)playerRunningState
+{
+ NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications];
+ int i;
+ int count = [apps count];
+
+ for (i = 0; i < count; i++) {
+ if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
+ return ITMTRemotePlayerRunning;
+ }
+ }
+ return ITMTRemotePlayerNotRunning;
+}
+
+- (ITMTRemotePlayerPlayingState)playerPlayingState
+{
+ long result = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pPlS'), from:'null'() }" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
+
+ switch (result)
+ {
+ default:
+ case 'kPSS':
+ return ITMTRemotePlayerStopped;
+ case 'kPSP':
+ return ITMTRemotePlayerPlaying;
+ case 'kPSp':
+ return ITMTRemotePlayerPaused;
+ case 'kPSR':
+ return ITMTRemotePlayerRewinding;
+ case 'kPSF':
+ return ITMTRemotePlayerForwarding;
+ }
+
+ return ITMTRemotePlayerStopped;
+}
+
+- (NSArray *)playlists
+{
+ long i = 0;
+ const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':(), &subj:()" eventClass:@"core" eventID:@"cnte" appPSN:iTunesPSN];
+ NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:numPlaylists];
+
+ for (i = 1; i <= numPlaylists; i++) {
+ const long j = i;
+ NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j];
+ NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
+ [playlists addObject:theObj];
+ }
+ return [playlists autorelease];
+}
+
+- (int)numberOfSongsInPlaylistAtIndex:(int)index
+{
+ return [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() }",index] eventClass:@"core" eventID:@"cnte" appPSN:iTunesPSN];
+}
+
+- (ITMTRemotePlayerPlaylistClass)classOfPlaylistAtIndex:(int)index
+{
+ int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
+
+
+ switch (realResult)
+ {
+ case 'cLiP':
+ return ITMTRemotePlayerLibraryPlaylist;
+ break;
+ case 'cRTP':
+ return ITMTRemotePlayerRadioPlaylist;
+ break;
+ default:
+ return ITMTRemotePlayerPlaylist;
+ }