+- (NSString *)playerSimpleName
+{
+ return @"iTunes";
+}
+
+- (NSDictionary *)capabilities
+{
+ 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
+{
+ ITDebugLog(@"Showing player primary interface.");
+
+ if ([self playerRunningState] == ITMTRemotePlayerRunning) {
+ ITDebugLog(@"Showing player interface.");
+ //If not minimized and visible
+ if ( ([[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] == 0) &&
+ ([[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pvis'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] != 0) &&
+ [[[[NSWorkspace sharedWorkspace] activeApplication] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"] ) {
+ //set minimized of browser window 1 to true
+ [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:long(1), '----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"setd" appPSN:savedPSN];
+ } else {
+ //set minimized of browser window 1 to false
+ [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:long(0), '----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"setd" appPSN:savedPSN];
+ }
+ //set visible of browser window 1 to true
+ [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:long(1), '----':obj { form:'prop', want:type('prop'), seld:type('pvis'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"setd" appPSN:savedPSN];
+ //active iTunes
+ [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:long(1), '----':obj { form:'prop', want:type('prop'), seld:type('pisf'), from:'null'() }" eventClass:@"core" eventID:@"setd" appPSN:savedPSN];
+ ITDebugLog(@"Done showing player primary interface.");
+ return YES;
+ } else {
+ NSString *path;
+ ITDebugLog(@"Launching player.");
+ if ( (path = [[NSUserDefaults standardUserDefaults] stringForKey:@"CustomPlayerPath"]) ) {
+ } else {
+ path = [self playerFullName];
+ }
+ if (![[NSWorkspace sharedWorkspace] launchApplication:path]) {
+ ITDebugLog(@"Error Launching Player");
+ return NO;
+ }
+ return YES;
+ }