user2121934
user2121934

Reputation: 1

An MPMediaQuery for playlists (on iPod) includes some albums

I've instantiated a query to request a collection of all the playlists on my iPod Touch. The result, returned from the MPMediaQuery collections property, contains 43 items. These include all 17 of the PlayLists that the native Music app shows. However, the collection also contains 26 "playlists" that are actually albums from my iPod library. That represents some(but not all) of the albums on the iPod.

I've tried to see if there was an MPMediaPlaylist attribute that might distinguish the albums from actual playlists, to no avail. I looked at the sections of the collection to see if real playlists are kept in a separate sections from the albums, but there was only a single section. Finally, I looked to see if the albums have a PersistantID, which the documentation indicates is unique to playlists. All the items in the array have a PersistantID.

The Music app has no trouble displaying just the 17 actual playlists, so there must be something I'm missing. Here is the code used to build the query:

MPMediaQuery * myPlaylistsQuery = [ MPMediaQuery playlistsQuery ];
NSArray      * playlists        = [ myPlaylistsQuery collections ];

Here is a sample of the data that gets logged when the contents of the "playlists" array is interrogated:

=====================================================
List of playlists
.... There are 01 sections in the playlist collection
.... There are 43 MPMediaPlaylist objects in the playlist collection
Bach
.... Persistant ID: 17002820337772537981
Best of Simon and Garfunkel
.... Persistant ID: 2965021518813542622
Blue
.... Persistant ID: 11514004552991695558
Blues
.... Persistant ID: 14243796139384893728
.... (etc)

In the above listing, the entries "Bach", "Best of Simon and Garfunkel" and "Blue" represent albums. The entry "Blues" represents the first of the true playlists that I've defined on iTunes.

I suppose that I could compare the items returned from the playlist query against a the items in an albums query, and eliminate any matches. Is there a more straightforward solution?

Upvotes: 0

Views: 697

Answers (1)

miho
miho

Reputation: 12085

I'm using [[MPMediaQuery playlistsQuery] collections] frequently and never have get an album returned as result. I guess that there is an issue somewhere else in your code. For example you still can customize the playlistsQuery after creating it with adding/removing parameters manually and if you change to much you could even let the query return albums instead of playlists.

Especially check the groupingType property of the query. For the playlistQuery it should be set to MPMediaGroupingPlaylist per default, but maybe you have overridden or removed this property manually for your query.

Otherwise there only remains the possibility of an bug in your devices system API or iTunes library. But this is very, very, very unlikely!

Upvotes: 0

Related Questions