This is what I did:
This seems to be working fine when the app is in foreground. But, when it's in background and I get an interruption, the audio doesn't resume and I get this error:
Is there a way to resume the audio in this specific state?
Set AVAudioSession to active and its category to .playback on app launch
Registered to observe notifications of type interruptionNotification
Added Background Modes in the project settings under Signing & Capabilities
Code Block if options.contains(.shouldResume) { if musicWasPlaying { audioPlayer.play() } }
This seems to be working fine when the app is in foreground. But, when it's in background and I get an interruption, the audio doesn't resume and I get this error:
Code Block [aurioc] 1540: AUIOClient_StartIO failed (560557684) error 2 Error Domain=NSOSStatusErrorDomain Code=560557684 "(null)"
Is there a way to resume the audio in this specific state?