0

I have an albumId ( say "-7833645336740617216" ). I am looking at a method similar which can take this as an input, and return the MPMediaItemArtwork associated with this album.

Braiam
  • 1
  • 11
  • 47
  • 78
Amarsh
  • 11,214
  • 18
  • 53
  • 78

1 Answers1

0

One way is to fetch the album with a MPMediaPropertyPredicate, and perform a MPMediaQuery with the predicate. Then get the value of the MPMediaItemPropertyArtwork property from the representative item of the album:

- (MPMediaItemArtwork *)albumArtworkForAlbumID:(NSNumber *)albumID
{
    MPMediaPropertyPredicate *albumIDPredicate;
    albumIDPredicate = [MPMediaPropertyPredicate predicateWithValue:albumID
                                                        forProperty:MPMediaItemPropertyAlbumPersistentID];

    NSSet *predicateSet = [NSSet setWithObject:albumIDPredicate];
    MPMediaQuery *albumQuery;
    albumQuery = [[MPMediaQuery alloc] initWithFilterPredicates:predicateSet];

    MPMediaItemCollection *album;
    album = [albumQuery.collections firstObject];

    return [album.representativeItem valueForProperty:MPMediaItemPropertyArtwork];
}
Bryan Luby
  • 2,527
  • 22
  • 31