Hi, I am creating audio player in tvos which is quite similar to Podcast App (Playing in background and stoping when user press pause button from Tv Remote). It is working fine when app is in foreground but creating issue when app is background. Audio Player is not getting stopped when user is pressing play/Pause button from remote. I have added MPRemoteCommandCenter target to my home controller. And I am using my audio player as single ton class. Below is snap shot of my code
private func setUpCommand() {
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.playCommand.isEnabled = true
commandCenter.pauseCommand.isEnabled = true
commandCenter.playCommand.addTarget {(commandEvent) -> MPRemoteCommandHandlerStatus in
PodcastPlayer.shared.playPauseCommad()
return .success
}
commandCenter.pauseCommand.addTarget {(commandEvent) -> MPRemoteCommandHandlerStatus in
PodcastPlayer.shared.playPauseCommad()
return .success
}
}
Above code is not triggering when app is in background.