From a5c365dd668dee7c653dbafee270e5e05025a2ab Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Sun, 25 Jul 2004 16:29:56 +0000 Subject: [PATCH] Added a browse Artist menu. The playlist creation and everything is hooked up and works. Adding Albums now. --- ITMTRemote.h | 5 +++++ ITMTRemote.m | 5 +++++ MainController.h | 1 + MainController.m | 11 +++++++++++ MenuController.m | 2 +- iTunesRemote.m | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index 91c3512..9cd019b 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -424,6 +424,11 @@ er's process managment. */ - (BOOL)switchToEQAtIndex:(int)index; +/*! + * @method makePlaylistWithTerm:ofType: + */ +- (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type; + @end /*! diff --git a/ITMTRemote.m b/ITMTRemote.m index 183648f..3b4a828 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -304,4 +304,9 @@ return NO; } +- (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type +{ + return NO; +} + @end diff --git a/MainController.h b/MainController.h index e1ad2a4..21848e7 100755 --- a/MainController.h +++ b/MainController.h @@ -68,6 +68,7 @@ - (void)selectSongAtIndex:(int)index; - (void)selectSongRating:(int)rating; - (void)selectEQPresetAtIndex:(int)index; +- (void)makePlaylistWithTerm:(NSString *)term ofType:(int)type; - (void)showPlayer; - (void)showPreferences; - (void)showTestWindow; diff --git a/MainController.m b/MainController.m index 23a6d1e..5406ad9 100755 --- a/MainController.m +++ b/MainController.m @@ -557,6 +557,17 @@ static MainController *sharedController; [self timerUpdate]; } +- (void)makePlaylistWithTerm:(NSString *)term ofType:(int)type +{ + ITDebugLog(@"Making playlist with term %@, type %i", term, type); + NS_DURING + [[self currentRemote] makePlaylistWithTerm:term ofType:type]; + NS_HANDLER + [self networkError:localException]; + NS_ENDHANDLER + ITDebugLog(@"Done making playlist"); +} + - (void)showPlayer { ITDebugLog(@"Beginning show player."); diff --git a/MenuController.m b/MenuController.m index c207e66..88a94ba 100755 --- a/MenuController.m +++ b/MenuController.m @@ -854,7 +854,7 @@ ** 2 - Album ** 3 - Genre? */ - //[[MainController sharedController] createAndPlayPlaylistWithTerm:[sender representedObject] ofType:1]; + [[MainController sharedController] makePlaylistWithTerm:[sender representedObject] ofType:1]; } - (void)updateMenu diff --git a/iTunesRemote.m b/iTunesRemote.m index b4479a9..997922c 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -770,6 +770,38 @@ return YES; } +- (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type +{ + int i; + + //Get fixed indexing status + BOOL fixed = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pFix'), from:'null'() }", 'core', 'getd', &savedPSN) booleanValue]; + + //Enabled fixed indexing + ITSendAEWithString(@"data:long(1), '----':obj { form:'prop', want:type('prop'), seld:type('pFix'), from:'null'() }", 'core', 'setd', &savedPSN); + + //Search for the term + NSAppleEventDescriptor *searchResults = ITSendAEWithString([NSString stringWithFormat:@"pTrm:\"%@\", pAre:'%@', '----':obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:'null'() } }", term, ((type == 1) ? @"kSrR" : @"kSrL")], 'hook', 'Srch', &savedPSN); + + //Delete old MenuTunes playlist + ITSendAEWithString(@"'----':obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", 'core', 'delo', &savedPSN); + + //Create MenuTunes playlist + ITSendAEWithString(@"prdt:{ pnam:\"MenuTunes\" }, kocl:type('cPly'), &subj:()", 'core', 'crel', &savedPSN); + + //Duplicate search results to playlist + for (i = 1; i <= [searchResults numberOfItems]; i++) { + ITSendAEWithStringAndObject(@"insh:obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", [[searchResults descriptorAtIndex:i] aeDesc], 'core', 'clon', &savedPSN); + } + //Reset fixed indexing + ITSendAEWithString([NSString stringWithFormat:@"data:long(%i), '----':obj { form:'prop', want:type('prop'), seld:type('pFix'), from:'null'() }", fixed], 'core', 'setd', &savedPSN); + + //Play MenuTunes playlist + ITSendAEWithString(@"'----':obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", 'hook', 'Play', &savedPSN); + + return YES; +} + - (ProcessSerialNumber)iTunesPSN { /*NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; -- 2.20.1