feat: Continue to record audio when receiving a phone call (try to prevent interruptions) (#1278)

* feat: Continue to record audio when receiving a phone call (try to prevent interruptions)

Uses `setPrefersNoInterruptionsFromSystemAlerts` to prevent system alerts (like phone calls) from interrupting the audio session which records audio from the microphone.

* fix: Add `try`
This commit is contained in:
Marc Rousavy 2022-10-14 12:30:22 +02:00 committed by GitHub
parent cc7d195cbd
commit 4781ad9835
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,6 +92,12 @@ extension CameraView {
.allowBluetoothA2DP,
.defaultToSpeaker,
.allowAirPlay])
if #available(iOS 14.5, *) {
// prevents the audio session from being interrupted by a phone call
try AVAudioSession.sharedInstance().setPrefersNoInterruptionsFromSystemAlerts(true)
}
audioCaptureSession.startRunning()
} catch let error as NSError {
switch error.code {