MPMediaItemArtwork is null while cover is available in iTunes

大兔子大兔子 提交于 2019-11-29 07:23:45

As of iOS 8, MPMediaItem's selector imageWithSize:(CGSize)size appears to not guarantee that it will return an image. If no image is returned at the requested size, call it again with the size of the artwork bounds property:

MPMediaItemArtwork *artwork = [self valueForProperty:MPMediaItemPropertyArtwork];
UIImage *image = [artwork imageWithSize:size];
if (image == nil) {
    image = [artwork imageWithSize:artwork.bounds.size];
}

i´ve found the problem.

it´s

 CGSize artworkImageViewSize = CGSizeMake(100, 100);

the following works:

 CGSize artworkImageViewSize = CGSizeMake(120, 120);

or

 CGSize artworkImageViewSize = CGSizeMake(60, 60);

everything that can be divided by 3 works.

Your code looks fine. I have the same code for getting artwork and it's working for me on iOS 8. Are you SURE the item actually has artwork? Play that song in the music app - artwork?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!