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:
parent
cc7d195cbd
commit
4781ad9835
@ -92,6 +92,12 @@ extension CameraView {
|
|||||||
.allowBluetoothA2DP,
|
.allowBluetoothA2DP,
|
||||||
.defaultToSpeaker,
|
.defaultToSpeaker,
|
||||||
.allowAirPlay])
|
.allowAirPlay])
|
||||||
|
|
||||||
|
if #available(iOS 14.5, *) {
|
||||||
|
// prevents the audio session from being interrupted by a phone call
|
||||||
|
try AVAudioSession.sharedInstance().setPrefersNoInterruptionsFromSystemAlerts(true)
|
||||||
|
}
|
||||||
|
|
||||||
audioCaptureSession.startRunning()
|
audioCaptureSession.startRunning()
|
||||||
} catch let error as NSError {
|
} catch let error as NSError {
|
||||||
switch error.code {
|
switch error.code {
|
||||||
|
Loading…
Reference in New Issue
Block a user