Search code examples
objective-ciosmpmediaquery

MPMediaQuery artistsQuery returns duplicates


I am using the Apple Media Player Framework in my application. To fetch items I am using the MPMediaQuery as described in their documents. Which works well, but when using the predefined query to retrieve all artists, I get duplicated entries for few artists.

Can somebody explain why there are duplicates? How do I suppress them?

NSArray *collections = [[MPMediaQuery artistsQuery] collections];

(And no there aren't any typos or differences in the casing in the name of the artist!)


Solution

  • I've noticed that this occurs only when there are albums with multiple artists.

    Instead of just [MPMediaQuery artistQuery], the following pretends this behavior:

    MPMediaQuery *artistsQuery = [MPMediaQuery artistsQuery];
    artistsQuery.groupingType = MPMediaGroupingAlbumArtist; 
    NSArray *collections = [artistQuery collection];