Skip to content

Commit

Permalink
Have ElementCall always default to the speaker; prevent the lock butt…
Browse files Browse the repository at this point in the history
…on from ending the call

- previously handled in 7818fa6
- seems the default behavior changed and we now need to manually configure the AudioSession
  • Loading branch information
stefanceriu committed Sep 27, 2024
1 parent 3b8da1c commit 4080ff1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ElementX/Sources/Services/ElementCall/ElementCallService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4080ff1

Please sign in to comment.