Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

ios - How to Set Artwork Image for MPNowPlayingInfoCenter

I've been trying to update the artwork shown for an item in MPNowPlayingInfoCenter using MPMediaItemPropertyArtwork as shown in the following code taken from Apple's docs

if let image = UIImage(named: "image_here") {
    nowPlayingInfo[MPMediaItemPropertyArtwork] =
        MPMediaItemArtwork(boundsSize: image.size) { size in
            return image
    }
}

The issue I'm having is that this sets a smaller image as shown in the photo below in the red square. I'm trying to figure out how to set the image in the larger yellow square, and I can't find any documentation that differentiates between the two.

enter image description here

EDIT

vint's answer below clarified that the smaller icon is the app icon. I am however setting the nowPlayingInfo dictionary successfully since my other metadata is reaching the lock screen controls, like the title (blurred), duration, elapsed playback time). It's just the artwork that appears to not being working.

question from:https://stackoverflow.com/questions/66056233/how-to-set-artwork-image-for-mpnowplayinginfocenter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Obviously you did not successfully set the cover image of the track to MPNowPlayingInfoCenter, The image in red square is your app icon, this is MPNowPlayingInfoCenter's default behavior,

I guess you lost the next step

// set the info dictionary back to default control center
MPNowPlayingInfoCenter.default.nowPlayingInfo = nowPlayingInfo

If you has set that, you should find the failed reason, seed this answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...