I am trying to retrieve the image of the currently playing song in the native music app. I can retrieve the title, artist, and album, but when I try to set the image of the artwork nothing happens.
if let nowPlaying = musicPlayer.nowPlayingItem {
let title = nowPlaying[MPMediaItemPropertyTitle] as? String
let artist = nowPlaying[MPMediaItemPropertyArtist] as? String
let album = nowPlaying[MPMediaItemPropertyAlbumTitle] as? String
let duration = nowPlaying[MPMediaItemPropertyPlaybackDuration] as? NSNumber
let artwork = nowPlaying[MPMediaItemPropertyArtwork] as? MPMediaItemArtwork
print("Artwork: \(artwork?.description)") //prints: Artwork: Optional(<MPConcreteMediaItemArtwork: 0x1756bc90>)
print("Song: \(title)")
print("Artist: \(artist)")
print("Album: \(album)")
controltitle.text = title!
controlartist.text = artist!
artworkimage.image = artwork!.imageWithSize(CGSize(width: artworkimage.bounds.width, height: artworkimage.bounds.height))
}