diff --git a/Spotlight/SpotlightPlaylistEntry.m b/Spotlight/SpotlightPlaylistEntry.m index 399eeeb6d..fcbc228d3 100644 --- a/Spotlight/SpotlightPlaylistEntry.m +++ b/Spotlight/SpotlightPlaylistEntry.m @@ -13,6 +13,9 @@ static NSArray * mdKeys; // Corresponding array for playlist entry keys static NSArray * entryKeys; + +// extramdKeys represents those keys that require additional processing +static NSArray * extramdKeys; // And the dictionary that matches them static NSDictionary * tags; @@ -37,6 +40,9 @@ static NSDictionary * tags; @"year", @"genre", nil]; + extramdKeys = [NSArray arrayWithObjects: + @"kMDItemPath", + nil]; tags = [NSDictionary dictionaryWithObjects:entryKeys forKeys:mdKeys]; } @@ -45,11 +51,14 @@ static NSDictionary * tags; // use the matching tag sets to generate a playlist entry SpotlightPlaylistEntry *entry = [[[SpotlightPlaylistEntry alloc] init] autorelease]; NSDictionary *songAttributes = [metadataItem valuesForAttributes:mdKeys]; + NSDictionary *extraAttributes = [metadataItem valuesForAttributes:extramdKeys]; for (NSString * mdKey in tags) { [entry setValue: [songAttributes objectForKey:mdKey] forKey:[tags objectForKey:mdKey]]; } + // URL needs to be generated from the simple path stored in kMDItemPath + [entry setURL: [NSURL fileURLWithPath: [extraAttributes objectForKey:@"kMDItemPath"]]]; return entry; } diff --git a/Spotlight/SpotlightSearchController.m b/Spotlight/SpotlightSearchController.m index d1121e845..694427b2e 100644 --- a/Spotlight/SpotlightSearchController.m +++ b/Spotlight/SpotlightSearchController.m @@ -90,12 +90,8 @@ static NSPredicate * musicOnlyPredicate = nil; { [self.query disableUpdates]; - NSArray *songPaths = [[playlistController selectedObjects]valueForKey:@"kMDItemPath"]; - NSMutableArray *songURLs = [NSMutableArray arrayWithCapacity:[songPaths count]]; - for (NSString *songPath in songPaths) { - [songURLs addObject:[NSURL fileURLWithPath:songPath]]; - } - [spotlightWindowController.playlistLoader addURLs:songURLs sort:NO]; + NSArray *songURLs = [[playlistController selectedObjects]valueForKey:@"url"]; + [spotlightWindowController.playlistLoader addURLs:songURLs sort:NO]; [self.query enableUpdates]; }