currentRemote = [self loadRemote];
[currentRemote begin];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iTunesTerminated:) name:@"ITMTRemoteAppDidTerminateNotification" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iTunesLaunched:) name:@"ITMTRemoteAppDidLaunchNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(remotePlayerTerminated:) name:@"ITMTRemoteAppDidTerminateNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(remotePlayerLaunched:) name:@"ITMTRemoteAppDidLaunchNotification" object:nil];
[self registerDefaultsIfNeeded];
menu = [[NSMenu alloc] initWithTitle:@""];
if ([currentRemote isAppRunning]) {
- [self iTunesLaunched:nil];
+ [self remotePlayerLaunched:nil];
} else {
- [self iTunesTerminated:nil];
+ [self remotePlayerTerminated:nil];
}
statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
}
}
-// if ( [remoteArray count] > 0 ) {
+// if ( [remoteArray count] > 0 ) { // UNCOMMENT WHEN WE HAVE > 1 PLUGIN
// if ( [remoteArray count] > 1 ) {
// [remoteArray sortUsingSelector:@selector(sortAlpha:)];
// }
// [self loadModuleAccessUI]; //Comment out this line to disable remote visibility
// }
}
- NSLog(@"%@", [remoteArray objectAtIndex:0]);
+// NSLog(@"%@", [remoteArray objectAtIndex:0]); //DEBUG
return [remoteArray objectAtIndex:0];
}
@"<separator>",
@"Upcoming Songs",
@"Playlists",
+ @"Song Rating",
@"<separator>",
@"PreferencesÉ",
@"Quit",
[menu addItemWithTitle:@"No Song"
action:nil
keyEquivalent:@""];
+ } else if ([item isEqualToString:@"Song Rating"]) {
+ NSMenu *ratingSubmenu = [[NSMenu alloc] initWithTitle:@""];
+ unichar whiteStar = 'o';//2606;
+ unichar blackStar = 'x';//2605;
+ NSString *whiteStarString = [NSString stringWithCharacters:&whiteStar
+ length:1];
+ NSString *blackStarString = [NSString stringWithCharacters:&blackStar
+ length:1];
+ NSString *string = @"";
+ int i;
+
+ for (i = 0; i < 5; i++) {
+ string = [string stringByAppendingString:whiteStarString];
+ }
+ for (i = 0; i < 6; i++) {
+ NSMenuItem *ratingItem;
+ ratingItem = [ratingSubmenu addItemWithTitle:string action:@selector(setSongRating:) keyEquivalent:@""];
+ [ratingItem setTarget:self];
+ [ratingItem setTag:i * 20];
+ string = [string substringToIndex:4];
+ string = [blackStarString stringByAppendingString:string];
+ }
+ [[menu addItemWithTitle:@"Song Rating"
+ action:nil
+ keyEquivalent:@""] setSubmenu:ratingSubmenu];
+ [ratingSubmenu autorelease];
} else if ([item isEqualToString:@"<separator>"]) {
[menu addItem:[NSMenuItem separatorItem]];
}
}
}
-- (void)iTunesLaunched:(NSNotification *)note
+- (void)remotePlayerLaunched:(NSNotification *)note
{
isAppRunning = YES;
[statusItem setMenu:menu]; //Set the menu back to the main one
}
-- (void)iTunesTerminated:(NSNotification *)note
+- (void)remotePlayerTerminated:(NSNotification *)note
{
isAppRunning = NO;
[playPauseMenuItem setTitle:@"Play"];
}
+- (void)setSongRating:(id)sender
+{
+ //[currentRemote setCurrentSongRating:[sender tag]];
+}
+
//
//
// Plugin independent selectors