我已经获得了一些NowPlaying视图文本元素,可以使用此元素来工作:
func updateInfoState(){
let artwork = MPMediaItemArtwork.init(boundsSize: self.uiImage.size, requestHandler: { (size) -> UIImage in
return self.uiImage
})
MPNowPlayingInfoCenter.default().nowPlayingInfo = [MPMediaItemPropertyAlbumTitle: title,
MPMediaItemPropertyArtist: author,
MPMediaItemPropertyTitle: trackName,
MPMediaItemPropertyArtwork:artwork,
MPNowPlayingInfoPropertyElapsedPlaybackTime: 0.0,
MPNowPlayingInfoPropertyPlaybackRate: 1.0,
MPNowPlayingInfoPropertyIsLiveStream: false,
]
}
但是我无法获得播放位置的更新。我正在尝试MPNowPlayingInfoPropertyElapsedPlaybackTime
和MPNowPlayingInfoPropertyPlaybackRate
,但实际上它们什么也没做。任何帮助将不胜感激。