diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index 980e9b5f3..9555d62e8 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -103,6 +103,17 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe } catch { MXLog.error("Failed requesting start call action with error: \(error)") } + + do { + // Have ElementCall default to the speaker so that the lock button doesn't end the call. + // Could also use `overrideOutputAudioPort` but the documentation is clear about it: + // `Sessions using PlayAndRecord category that always want to prefer the built-in + // speaker output over the receiver, should use AVAudioSessionCategoryOptionDefaultToSpeaker instead.`. + try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [.defaultToSpeaker]) + try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) + } catch { + MXLog.error("Failed setting up audio session with error: \(error)") + } } func tearDownCallSession() {