From: Kent Sutherland Date: Fri, 12 Dec 2003 00:06:37 +0000 (+0000) Subject: Added multisource playlists. Doesn't play yet, and it shows the radio X-Git-Tag: v1.2~14 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/a39da95b62217faccd6f43d22f20c5637cf10196 Added multisource playlists. Doesn't play yet, and it shows the radio source. It also doesn't select the current source yet either. --- diff --git a/MainController.m b/MainController.m index dafd199..b041679 100755 --- a/MainController.m +++ b/MainController.m @@ -406,7 +406,7 @@ static MainController *sharedController; { ITDebugLog(@"Selecting playlist %i", index); NS_DURING - [[self currentRemote] switchToPlaylistAtIndex:index]; + [[self currentRemote] switchToPlaylistAtIndex:(index / 1000) ofSourceAtIndex:(index % 1000)]; NS_HANDLER [self networkError:localException]; NS_ENDHANDLER diff --git a/MenuController.m b/MenuController.m index f360033..0998e06 100755 --- a/MenuController.m +++ b/MenuController.m @@ -527,14 +527,13 @@ return upcomingSongsMenu; } -- (NSMenu *)playlistsMenu +/*- (NSMenu *)playlistsMenu { NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""]; NSArray *playlists; NSMenuItem *tempItem; ITMTRemotePlayerSource source = [[[MainController sharedController] currentRemote] currentSource]; int i; - NS_DURING playlists = [[[MainController sharedController] currentRemote] playlists]; NS_HANDLER @@ -566,6 +565,64 @@ } ITDebugLog(@"Done Building \"Playlists\" menu"); return playlistsMenu; +}*/ + + +- (NSMenu *)playlistsMenu +{ + NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""]; + NSArray *playlists; + NSMenuItem *tempItem; + ITMTRemotePlayerSource source = [[[MainController sharedController] currentRemote] currentSource]; + int i, j; + NS_DURING + playlists = [[[MainController sharedController] currentRemote] playlists]; + NS_HANDLER + [[MainController sharedController] networkError:localException]; + NS_ENDHANDLER + ITDebugLog(@"Building \"Playlists\" menu."); + { + NSArray *curPlaylist = [playlists objectAtIndex:0]; + NSString *name = [curPlaylist objectAtIndex:0]; + ITDebugLog(@"Adding main source: %@", name); + for (i = 1; i < [curPlaylist count]; i++) { + ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:i]); + tempItem = [playlistsMenu addItemWithTitle:[curPlaylist objectAtIndex:i] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""]; + [tempItem setTag:i + 1]; + [tempItem setTarget:self]; + } + } + + [playlistsMenu addItem:[NSMenuItem separatorItem]]; + + for (i = 1; i < [playlists count]; i++) { + NSArray *curPlaylist = [playlists objectAtIndex:i]; + NSString *name = [curPlaylist objectAtIndex:0]; + NSMenu *submenu = [[NSMenu alloc] init]; + ITDebugLog(@"Adding source: %@", name); + for (j = 1; j < [curPlaylist count]; j++) { + ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:j]); + tempItem = [submenu addItemWithTitle:[curPlaylist objectAtIndex:j] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""]; + [tempItem setTag:(j * 1000) + (j + 1)]; + [tempItem setTarget:self]; + } + [[playlistsMenu addItemWithTitle:name action:NULL keyEquivalent:@""] setSubmenu:[submenu autorelease]]; + } + /*if (source == ITMTRemoteRadioSource) { + [[playlistsMenu addItemWithTitle:NSLocalizedString(@"radio", @"Radio") action:NULL keyEquivalent:@""] setState:NSOnState]; + } else if (source == ITMTRemoteGenericDeviceSource) { + [[playlistsMenu addItemWithTitle:NSLocalizedString(@"genericDevice", @"Generic Device") action:NULL keyEquivalent:@""] setState:NSOnState]; + } else if (source == ITMTRemoteiPodSource) { + [[playlistsMenu addItemWithTitle:NSLocalizedString(@"iPod", @"iPod") action:NULL keyEquivalent:@""] setState:NSOnState]; + } else if (source == ITMTRemoteCDSource) { + [[playlistsMenu addItemWithTitle:NSLocalizedString(@"cd", @"CD") action:NULL keyEquivalent:@""] setState:NSOnState]; + } else if (source == ITMTRemoteSharedLibrarySource) { + [[playlistsMenu addItemWithTitle:NSLocalizedString(@"sharedLibrary", @"Shared Library") action:NULL keyEquivalent:@""] setState:NSOnState]; + } else if (source == ITMTRemoteLibrarySource && _currentPlaylist) { + [[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState]; + }*/ + ITDebugLog(@"Done Building \"Playlists\" menu"); + return playlistsMenu; } - (NSMenu *)eqMenu diff --git a/iTunesRemote.m b/iTunesRemote.m index 68890d3..108c9ce 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -123,7 +123,7 @@ return ITMTRemotePlayerStopped; } -- (NSArray *)playlists +/*- (NSArray *)playlists { long i = 0; const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; @@ -136,21 +136,30 @@ [playlists addObject:theObj]; } return [playlists autorelease]; - /*unsigned long i,k; +}*/ + +//Full source awareness +- (NSArray *)playlists +{ unsigned long i,k; const signed long numSources = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cSrc'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; - NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:1]; + NSMutableArray *allSources = [[NSMutableArray alloc] init]; ITDebugLog(@"Getting playlists."); for (k = 1; k <= numSources ; k++) { const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cPly'), '----':obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() }",k] eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; + NSString *sourceName = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k] eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; + NSMutableArray *aSource = [[NSMutableArray alloc] init]; + [aSource addObject:sourceName]; for (i = 1; i <= numPlaylists; i++) { NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%u), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } } }",i,k]; NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; - [playlists addObject:theObj]; + [aSource addObject:theObj]; } + [allSources addObject:aSource]; + [aSource release]; } ITDebugLog(@"Finished getting playlists."); - return [playlists autorelease];*/ + return [NSArray arrayWithArray:[allSources autorelease]]; } - (int)numberOfSongsInPlaylistAtIndex:(int)index @@ -583,6 +592,15 @@ return YES; } +- (BOOL)switchToPlaylistAtIndex:(int)index ofSourceAtIndex:(int)index2 +{ + ITDebugLog(@"Switching to playlist at index %i of source %i", index, index2); + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'indx', want:type('cSrc'), seld:long('%lu'), from:() } }",index, index2] eventClass:@"hook" eventID:@"Play" appPSN:savedPSN]; + //[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() }, data:obj { form:'indx', want:type('cSrc'), seld:long('%lu'), from:'null'() }",index, index2] + ITDebugLog(@"Done switching to playlist at index %i of source %i", index, index2); + return YES; +} + - (BOOL)switchToSongAtIndex:(int)index { ITDebugLog(@"Switching to track at index %i", index); diff --git a/libValidate.a b/libValidate.a index 336b657..6f4a9db 100755 Binary files a/libValidate.a and b/libValidate.a differ