4

I am working on an iOS app and I need to determine if a song has album art. I am using the MPMusicPlayerController to access the native iOS music library and I am using a MPMediaItemArtwork to capture the artwork sent from the iOS music library. This is the coding I use to get the artwork:

MPMediaItemArtwork *mpArt = [mpSong valueForProperty:MPMediaItemPropertyArtwork];

To test if artwork is present I use this:

if (mpArt)
{
    imgArt = [mpArt imageWithSize:CGSizeMake(250, 250)];
}
else
{
    imgArt = [UIImage imageNamed:@"Alternative_Artwork_Image.jpg"];
}

No matter what the song's artwork is, the result is always true.

Any help would be appreciated. Thank you in advance.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
JDVDV5
  • 55
  • 5

1 Answers1

0

I think it will always return true if it is an iCloud selection because it will eventually download. Try looking for a correlation with MPMediaItemPropertyIsCloudItem

You can also try getting info from the bounds... perhaps the bounds is 0x0 when the image is not found.

coneybeare
  • 33,113
  • 21
  • 131
  • 183
  • The device I am using for testing does not have any music from iCloud. Everything is locally and offline... But thanks anyway. Will look into it for future development – JDVDV5 Dec 31 '13 at 00:50
  • Can you get any other info out of it, like perhaps the [bounds](https://developer.apple.com/Library/ios/documentation/MediaPlayer/Reference/MPMediaItemArtwork_ClassReference/Reference/Reference.html#//apple_ref/occ/instp/MPMediaItemArtwork/bounds) is 0x0 or something. – coneybeare Dec 31 '13 at 00:56
  • Thanks for the idea. Was able to use the bounds as a way to determine if artwork is present. Thanks a lot!!! – JDVDV5 Dec 31 '13 at 01:24
  • No problem. If the answer was correct for you, please mark it as such by clicking the green checkmark next to it. – coneybeare Dec 31 '13 at 02:17