简体   繁体   中英

Setting a cover with MPMediaItemArtwork not working iOS 16

I am building an app with AVKit and MediaPlayer and want to show a cover in the control center. Using this code didn't worked for me:

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

First, I thought that downloading the UI Image failed, but then i realised that this issue also happend when using a locally saved image.

By the way: Setting up the player (pause/play/background mode) worked fine.

I am using iOS 16 and Xcode 14.0.1.

where is your nowPlayingInfo coming from? In my process I declare a new dictionary with titles and stuff then I process my image later with async download using

 MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyArtwork] = artwork

I mean if you directly set it in the default Center is it still not showing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM