MPMediaQuery artistsQuery returns duplicates
Asked Answered
M

1

8

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!)

Mcmillin answered 6/11, 2012 at 18:39 Comment(4)
For starters, there could be some meta that causes duplication. However, to confirm this, how about creating an NSSet using the NSArray which will automatically remove all duplicates? NSSet *uniqueArtists = [NSSet setWithArray:collections];. See if this removes the duplicates. Otherwise there must be something that makes the artists duplicate despite same artist name.Gennie
Poorly that's not possible, since I also want to use the sections feature of MPMediaQuery. Yep, but it would be interesting to find out what kind of meta data duplicates them and how to prevent.Mcmillin
do you see the same duplicate artists in the music app in the artists tab?Assertive
No, there aren't any duplicates in the Music app.Mcmillin
M
5

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];
Mcmillin answered 29/11, 2012 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.