I want to get the album art from a audiobook in the iPod library, But I do not understand how to use MPMediaItemPropertyArtwork
- (NSArray *)audiobooks
{
MPMediaPropertyPredicate *abPredicate =
[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInt:MPMediaTypeAudioBook]
forProperty:MPMediaItemPropertyMediaType];
MPMediaQuery *abQuery = [[MPMediaQuery alloc] init];
[abQuery addFilterPredicate:abPredicate];
[abQuery setGroupingType:MPMediaGroupingAlbum];
NSArray *books = [abQuery collections];
return books;
}
- (MPMediaItem *)mediaItemForRow: (NSInteger)row
{
NSArray *audiobooks = self.audiobooks;
MPMediaItem *mediaItem = nil;
for (id object in audiobooks) {
if ([object isKindOfClass:[MPMediaItemCollection class]]) {
MPMediaItemCollection *book = (MPMediaItemCollection *)object;
id item = [book items][row];
if ([item isKindOfClass:[MPMediaItem class]]) {
mediaItem = (MPMediaItem *)item;
}
}
}
return mediaItem;
}
So now I can get title of media item like this:
NSString *title = [mediaItem valueForProperty:MPMediaItemPropertyArtist];
But how do i get the artwork so I can display it in a UIImage? there is this property:
[mediaItem valueForProperty:MPMediaItemPropertyArtwork]
I have not managed to find out how to use it.