Posts

Post not yet marked as solved
0 Replies
529 Views
private func startPlaybackAudioSession() { let policy: AVAudioSession.RouteSharingPolicy if #available(iOS 13.0, *) { policy = .longFormAudio } else { policy = .longForm } try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, policy: policy, options: []) try? AVAudioSession.sharedInstance().setActive(true, options: []) }My app plays a live radio url. Whenever the user pause the AVPlayer and send the app to background, when he/she comes back, the player start playing again by itself. It seems that iOS sends a "play" message to my AVPlayer somewhere. How can I protect from this. I saw that I should not call:try? AVAudioSession.sharedInstance().setActive(false, options: [])as it is the OS responsability to do so.
Posted Last updated
.