- int playlist = [currentRemote currentPlaylistIndex];
- ITMTRemotePlayerPlayingState playerPlayingState = [currentRemote playerPlayingState];
-
- if ((playlist > 0) || playerPlayingState != ITMTRemotePlayerStopped) {
- int trackPlayingIndex = [currentRemote currentSongIndex];
-
- if (trackPlayingIndex != lastSongIndex) {
- BOOL wasPlayingRadio = isPlayingRadio;
- isPlayingRadio = ([currentRemote classOfPlaylistAtIndex:playlist] == ITMTRemotePlayerRadioPlaylist);
-
- if (isPlayingRadio && !wasPlayingRadio) {
- int i;
- for (i = 0; i < [playlistMenu numberOfItems]; i++)
- {
- [[playlistMenu itemAtIndex:i] setState:NSOffState];
- }
- } else {
- [[playlistMenu itemAtIndex:playlist - 1] setState:NSOnState];
- }
-
- if (wasPlayingRadio) {
- NSMenuItem *temp = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [menu insertItem:temp atIndex:trackInfoIndex + 1];
- [temp release];
- }
-
- [self updateMenu];
- lastSongIndex = trackPlayingIndex;
- } else {
- if (playlist != lastPlaylistIndex) {
- BOOL wasPlayingRadio = isPlayingRadio;
- isPlayingRadio = ([currentRemote classOfPlaylistAtIndex:playlist] == ITMTRemotePlayerRadioPlaylist);
-
- if (isPlayingRadio && !wasPlayingRadio) {
- int i;
- for (i = 0; i < [playlistMenu numberOfItems]; i++) {
- [[playlistMenu itemAtIndex:i] setState:NSOffState];
- }
- }
-
- if (wasPlayingRadio) {
- NSMenuItem *temp = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [menu insertItem:temp atIndex:trackInfoIndex + 1];
- [temp release];
- }
-
- if (!isPlayingRadio) {
- int i;
- for (i = 0; i < [playlistMenu numberOfItems]; i++)
- {
- [[playlistMenu itemAtIndex:i] setState:NSOffState];
- }
- [[playlistMenu itemAtIndex:playlist - 1] setState:NSOnState];
- }
-
- [self updateMenu];
- lastSongIndex = trackPlayingIndex;
- lastPlaylistIndex = playlist;
- }
- }
- //Update Play/Pause menu item
- if (playPauseMenuItem){
- if (playerPlayingState == ITMTRemotePlayerPlaying) {
- [playPauseMenuItem setTitle:@"Pause"];
- } else {
- [playPauseMenuItem setTitle:@"Play"];
- }
- }
- } else if ((lastPlaylistIndex > 0) && (playlist == 0)) {
- NSMenuItem *menuItem;
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- //Remote the now playing item and add no song item
- [menu removeItemAtIndex:trackInfoIndex];
-
- if ([defaults boolForKey:@"showName"] == YES) {
- [menu removeItemAtIndex:trackInfoIndex];
- }
-
- if ([defaults boolForKey:@"showTime"] == YES) {
- [menu removeItemAtIndex:trackInfoIndex];
- }
-
- if (didHaveArtistName && [defaults boolForKey:@"showArtist"]) {
- [menu removeItemAtIndex:trackInfoIndex];
- }
-
- if (didHaveAlbumName && [defaults boolForKey:@"showAlbum"]) {
- [menu removeItemAtIndex:trackInfoIndex];
- }
-
- [playPauseMenuItem setTitle:@"Play"];
-
- didHaveArtistName = NO;
- didHaveAlbumName = NO;
- lastPlaylistIndex = -1;
- lastSongIndex = -1;
-
- [upcomingSongsItem setSubmenu:nil];
- [upcomingSongsItem setEnabled:NO];
-
- [songRatingMenuItem setSubmenu:nil];
- [songRatingMenuItem setEnabled:NO];
-
- menuItem = [[NSMenuItem alloc] initWithTitle:@"No Song" action:nil keyEquivalent:@""];
- [menu insertItem:menuItem atIndex:trackInfoIndex];
- [menuItem release];