my goal cover picture playlists in ipod library. , did like
playlistmediaitemcollections = mpmediaquery.playlistsquery().collections ?? [] let artworks = playlistmediaitemcollections.map { $0.valueforkey(mpmediaitempropertyartwork) as? mpmediaitemartwork }
but results in error
terminating app due uncaught exception 'nsunknownkeyexception', reason: '[<mpconcretemediaplaylist 0x1468b1eb0> valueforundefinedkey:]: class not key value coding-compliant key artwork.'
anyone knows how can playlist artwork? thanks
you should use valueforproperty
instead:
$0.valueforproperty(mpmediaitempropertyartwork) as? mpmediaitemartwork
however, think unlike songs or albums, mediaplayer api not provide such property key lets retrieve artwork of playlist. can check out possible ones can used mpmediaplaylist class:
let mpmediaplaylistpropertypersistentid: string let mpmediaplaylistpropertyname: string let mpmediaplaylistpropertyplaylistattributes: string let mpmediaplaylistpropertyseeditems: string
one alternative is, can artworks of songs in playlist, , show either 1 of them or combine them create new artwork playlist.
i think music app same thing below if playlist doesn't have artwork image.
let playlist = mpmediaquery.playlistsquery().collections?.first let artworks = playlist?.items.map { $0.valueforproperty(mpmediaitempropertyartwork) as? mpmediaitemartwork }
Comments
Post a Comment