Is it possible to retrieve the music Playlist Artwork?

313 Views Asked by At

I'm trying to retrieve the artwork for a playlist (not the artwork for a song). The Apple music app let you create an image for a playlist but I can't seem to access it.

Is this possible? MPMediaItemPropertyArtwork is not listed as one of the Playlist Property Keys.

I'm trying the following:

let playlistItems: [MPMediaPlaylist] = playlistQuery.collections! as! [MPMediaPlaylist]

    for playlist in playlistItems {

        let artwork = playlist.value( forProperty: MPMediaItemPropertyArtwork ) as? MPMediaItemArtwork
        let sizeforArtwork = artwork?.bounds.size
        let artworkImage = artwork?.image(at: sizeforArtwork!)

        let playlistName = playlist.value( forProperty: MPMediaPlaylistPropertyName ) as! String

        let info: PlaylistInfo = PlaylistInfo(
            playlistTitle: playlistName,
            playlistImage: artworkImage
        )
        playlists.append(info)
    }

And

struct PlaylistInfo {
var playlistTitle: String
var playlistImage: UIImage?
}

var playlists: [PlaylistInfo] = []
0

There are 0 best solutions below