objective-ciosmedia-playeritunesartwork

Mediaplayer no album artwork placeholder


I'm using the media player framework to get the artwork of the song that's currently playing, but every time a song is played that has no album artwork, the UIImageView I load the artwork into is empty. Is there a way to have a placeholder image that is displayed every time a song with no artwork is played?


Solution

  • This is how I use a placeholder for songs that do not have artwork:

    artworkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(x,y,160,160)];
    
    CGSize artworkImageViewSize = artworkImageView.bounds.size;
    artwork = [currentItem valueForProperty:MPMediaItemPropertyArtwork];
    if (artwork != nil) {
        artworkImageView.image = [artwork imageWithSize:artworkImageViewSize];
    }else{
        artworkImageView.image = [UIImage imageNamed:@"NoAlbumArt.png"];
    }