I want to display the track info in a nowPlayingTemplate, how can i send it the info or configure it?
This is my code:
itemLista = CPListItem(text: podcast.name, detailText: podcast.date)
itemLista.handler = { [weak self] item, completion in
guard let this = self else { return }
let nowPlayingTemplate = CPNowPlayingTemplate.shared
nowPlayingTemplate.add(this)
this.playWithItems(items: [podcast.identifier!])
var nowPlayingInfo = [String: Any]()
nowPlayingInfo[MPMediaItemPropertyTitle] = "Title"
nowPlayingInfo[MPMediaItemPropertyArtist] = "Artist"
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
this.interfaceController!.pushTemplate(nowPlayingTemplate, animated: true, completion: nil)
completion()
}
func playWithItems(items: [String]) {
MPMusicPlayerController.applicationQueuePlayer.pause()
MPMusicPlayerController.applicationQueuePlayer.setQueue(with: items)
MPMusicPlayerController.applicationQueuePlayer.prepareToPlay()
MPMusicPlayerController.applicationQueuePlayer.play()
}