X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/780d4fc50b96f49e391ebb704716feaa5e14356c..2404965b693451fd71dcffd06eb82695e9085389:/iTunesRemote.m?ds=sidebyside diff --git a/iTunesRemote.m b/iTunesRemote.m index 9ac0c15..68890d3 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -125,21 +125,32 @@ - (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]; + long i = 0; + const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; + NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:numPlaylists]; - 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]; 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]; + const long j = i; + NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j]; NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; [playlists addObject:theObj]; } + return [playlists autorelease]; + /*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]; + + 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]; + 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]; + } } ITDebugLog(@"Finished getting playlists."); - return [playlists autorelease]; + return [playlists autorelease];*/ } - (int)numberOfSongsInPlaylistAtIndex:(int)index @@ -176,12 +187,12 @@ ITDebugLog(@"Getting current source done. Source: CD."); return ITMTRemoteCDSource; break; - case 'kUnk': - case 'kLib': case 'kShd': ITDebugLog(@"Getting current source done. Source: Shared Library."); return ITMTRemoteSharedLibrarySource; break; + case 'kUnk': + case 'kLib': default: ITDebugLog(@"Getting current source done. Source: Library."); return ITMTRemoteLibrarySource;