I got the answer. As soon as I registered for remote controls the MPMediaInfo appeared correctly
Post
Replies
Boosts
Views
Activity
I discovered that what was causing the MPNowPlayingInfoCenter to be update was the AVPlayerViewController (as I believed) setting controller.updatesNowPlayingInfoCenter = false prevented this unwanted update
Now a new issue appears, the MPNowPlayingInfoCenter doesn't appear at all
On the init() I have this line to monitor the playback status
player.publisher(for: \.timeControlStatus)
.sink { [weak self] status in
switch status {
case .playing:
self?.isPlaying = true
try? AVAudioSession.sharedInstance().setActive(true)
self?.setupNowPlaying()
case .paused:
self?.isPlaying = false
case .waitingToPlayAtSpecifiedRate:
break
@unknown default:
break
}
}
.store(in: &subscriptions)
Here's the function that updates (or at least should) update the MPNowPlayingInfo
func setupNowPlaying() {
var nowPlayingInfo = [String: Any]()
nowPlayingInfo[MPNowPlayingInfoPropertyMediaType] = MPNowPlayingInfoMediaType.audio.rawValue
nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = false
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = player.rate
nowPlayingInfo[MPMediaItemPropertyTitle] = "Track Title"
nowPlayingInfo[MPMediaItemPropertyArtist] = "Track Artist"
nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
}
I feel that I'm close to the answer but still out of reach
So I already had the Info.plist on my project but if you don't have one you must create one and place it on the root of the project
Then go to the Target -> Build Settings -> Packaging -> Info.plist File and change the value to "target/Info.plist" in my case it's "swarm/Info.plist"
This was still causing the error to appear but adding the following key to the Info.plist fixed it
If you add a new key and start typing and then use the auto complete it should add the child keys as well
You don't really need to add anything to the "Scene Configuration"