Added a browse Artist menu. The playlist creation and everything is
authorKent Sutherland <ksuther@ithinksw.com>
Sun, 25 Jul 2004 16:29:56 +0000 (16:29 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Sun, 25 Jul 2004 16:29:56 +0000 (16:29 +0000)
hooked up and works. Adding Albums now.

ITMTRemote.h
ITMTRemote.m
MainController.h
MainController.m
MenuController.m
iTunesRemote.m

index 91c3512..9cd019b 100755 (executable)
@@ -424,6 +424,11 @@ er's process managment.
  */
 - (BOOL)switchToEQAtIndex:(int)index;
 
  */
 - (BOOL)switchToEQAtIndex:(int)index;
 
+/*!
+ * @method makePlaylistWithTerm:ofType:
+ */
+- (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type;
+
 @end
 
 /*!
 @end
 
 /*!
index 183648f..3b4a828 100755 (executable)
     return NO;
 }
 
     return NO;
 }
 
+- (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type
+{
+    return NO;
+}
+
 @end
 @end
index e1ad2a4..21848e7 100755 (executable)
@@ -68,6 +68,7 @@
 - (void)selectSongAtIndex:(int)index;
 - (void)selectSongRating:(int)rating;
 - (void)selectEQPresetAtIndex:(int)index;
 - (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;
 - (void)showPlayer;
 - (void)showPreferences;
 - (void)showTestWindow;
index 23a6d1e..5406ad9 100755 (executable)
@@ -557,6 +557,17 @@ static MainController *sharedController;
     [self timerUpdate];
 }
 
     [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.");
 - (void)showPlayer
 {
     ITDebugLog(@"Beginning show player.");
index c207e66..88a94ba 100755 (executable)
     ** 2 - Album
     ** 3 - Genre?
     */
     ** 2 - Album
     ** 3 - Genre?
     */
-    //[[MainController sharedController] createAndPlayPlaylistWithTerm:[sender representedObject] ofType:1];
+    [[MainController sharedController] makePlaylistWithTerm:[sender representedObject] ofType:1];
 }
 
 - (void)updateMenu
 }
 
 - (void)updateMenu
index b4479a9..997922c 100755 (executable)
     return YES;
 }
 
     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];
 - (ProcessSerialNumber)iTunesPSN
 {
     /*NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications];