我试图在锁定屏幕中显示命令中心而不是为我工作,我看到了本教程中的代码,并编写了相同的代码但也无法正常工作 https://github.com/lukagabric/LGAudioPlayerLockScreen
这是代码
var nowPlayingInfo = [MPMediaItemPropertyTitle: currentPlaybackItem.trackName,
MPMediaItemPropertyAlbumTitle: currentPlaybackItem.albumName,
MPMediaItemPropertyArtist: currentPlaybackItem.artistName,
MPMediaItemPropertyPlaybackDuration: audioPlayer.duration,
MPNowPlayingInfoPropertyPlaybackRate: NSNumber(value: 1.0 as Float)] as [String : Any]
if let image = UIImage(named: currentPlaybackItem.albumImageName) {
nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(image: image)
}
self.nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo
任何人都可以提供帮助