3

How to manage to get the "Purchased" and "Purchased on my iPhone" MPMediaPlaylist, using localized strings name as playlists names:

NSArray *songs;
NSString *name=@"Purchased";
// @TODO
// need to get localized version of this default iOS playlist name
//
MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery];
    NSArray *playlists = [myPlaylistsQuery collections];
    NSArray *songs=nil;
    for (MPMediaPlaylist *playlist in playlists) {
        if( [name isEqualToString:[playlist valueForProperty: MPMediaPlaylistPropertyName]] ) {
            songs = [playlist items];
            break;
        }
}
loretoparisi
  • 15,724
  • 11
  • 102
  • 146

1 Answers1

1

I think it's probably worse than you expected - the language "Purchased" is in depends on the language of the users PC, not the current language the iPhone is set to. (Certainly, if I change my phone's language to Japanese, "Purchased on ipad" continues to show that name.

Unfortunately Apple doesn't seem to expose any kind of supported API to allow us to know which playlists are the "purchased" ones, at least in iOS6 and earlier.

So really you need check against "Purchased" in every possible language, not just the current language.

The ones I know are:

  • English: Purchased
  • Japanese: 購入したもの
JosephH
  • 37,173
  • 19
  • 130
  • 154