ui: do not enable speaker in calls when contact turned on video (#4998)

This commit is contained in:
Stanislav Dmitrenko
2024-10-08 21:57:33 +07:00
committed by GitHub
parent 6907f02ea6
commit 35fc0544a0
2 changed files with 6 additions and 5 deletions
@@ -434,12 +434,12 @@ struct ActiveCallOverlay: View {
audioDevicePickerButton()
}
}
.onChange(of: call.hasVideo) { hasVideo in
.onChange(of: call.localMediaSources.hasVideo) { hasVideo in
let current = AVAudioSession.sharedInstance().currentRoute.outputs.first?.portType
let speakerEnabled = current == .builtInSpeaker
let receiverEnabled = current == .builtInReceiver
// react automatically only when speaker or receiver were selected, otherwise keep an external device selected
if hasVideo != speakerEnabled && (speakerEnabled || receiverEnabled) {
// react automatically only when receiver were selected, otherwise keep an external device selected
if !speakerEnabled && hasVideo && receiverEnabled {
client.setSpeakerEnabledAndConfigureSession(!speakerEnabled, skipExternalDevice: true)
call.speakerEnabled = !speakerEnabled
}
@@ -226,8 +226,9 @@ actual fun ActiveCallView() {
ActiveCallOverlay(call, chatModel, callAudioDeviceManager)
}
}
KeyChangeEffect(call?.hasVideo) {
if (call != null) {
KeyChangeEffect(call?.localMediaSources?.hasVideo) {
if (call != null && call.hasVideo && callAudioDeviceManager.currentDevice.value?.type == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
// enabling speaker on user action (peer action ignored) and not disabling it again
callAudioDeviceManager.selectLastExternalDeviceOrDefault(call.hasVideo, true)
}
}