NSArray *menu = [[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"];
ITDebugLog(@"Rebuilding all of the submenus.");
NS_DURING
- _currentPlaylist = [[[MainController sharedController] currentRemote] currentPlaylistIndex];
- _currentTrack = [[[MainController sharedController] currentRemote] currentSongIndex];
+ _currentTrack = [[[MainController sharedController] currentRemote] currentSongIndex];
+ if (_currentTrack > -1) {
+ _currentPlaylist = [[[MainController sharedController] currentRemote] currentPlaylistIndex];
+ }
_playingRadio = ([[[MainController sharedController] currentRemote] currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist);
NS_HANDLER
[[MainController sharedController] networkError:localException];
- (NSMenu *)upcomingSongsMenu
{
- NSMenu *upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSMenu *upcomingSongsMenu;
int numSongs = 0, numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
+ if (_currentTrack == -1) {
+ return nil;
+ }
NS_DURING
numSongs = [[[MainController sharedController] currentRemote] numberOfSongsInPlaylistAtIndex:_currentPlaylist];
NS_HANDLER
NS_ENDHANDLER
if (numSongs == -1) {
- [upcomingSongsMenu release];
return nil;
}
+ upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
NS_DURING
ITDebugLog(@"Building \"Upcoming Songs\" menu.");
if (_currentPlaylist && !_playingRadio) {
NSString *temp1;
ITDebugLog(@"Getting current unique identifier.");
NSAppleEventDescriptor *descriptor = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN);
- if (descriptor == nil) {
- return nil;
+ if ((descriptor == nil) || ([descriptor int32Value] == 'prop')) {
+ return @"0-0";
}
SInt32 cls = [descriptor int32Value];
if ( ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist) || (cls == 'cURT') ) {
{
int temp1;
ITDebugLog(@"Getting current song index.");
- temp1 = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value];
+ temp1 = (([ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] != 'prop') ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] : -1);
ITDebugLog(@"Getting current song index done.");
return temp1;
}