turn speaker on in video call.

main_production_audio_video_call
Sikander Saleem 3 days ago
parent 29f5f82841
commit 6f4bc290c5

@ -88,6 +88,7 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
onSuccess = null;
isMuted = false;
isPeerMuted = false;
isSpeakerOn = false;
// `CallProvider` is a long-lived singleton (registered once in main.dart),
// so without resetting these here, toggling the camera off near the end
// of one video call would leak into the *next* call, making it look like
@ -176,6 +177,9 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
case RTCIceConnectionState.RTCIceConnectionStateConnected:
case RTCIceConnectionState.RTCIceConnectionStateCompleted:
if (currentStatus != "Connected") {
// The OS resets the audio route to the earpiece once media
// actually starts flowing, so re-apply it on connect.
_applyDefaultAudioRoute();
_setStatus("Connected");
_startCallDurationTimer();
}
@ -201,11 +205,23 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// on this singleton CallProvider (see endSession()).
isCameraOn = true;
isPeerCameraOn = true;
isSpeakerOn = true;
await _webRTCService.initializeForVideoCall();
_webRTCService.setCameraEnabled(true);
notifyListeners();
} else {
isSpeakerOn = false;
await _webRTCService.initializeForAudioCall();
notifyListeners();
}
}
void _applyDefaultAudioRoute() {
if (isVideo == true) {
isSpeakerOn = true;
_webRTCService.setSpeakerphoneEnabled(true);
} else {
_webRTCService.setSpeakerphoneEnabled(isSpeakerOn);
}
}

@ -269,6 +269,9 @@ class WebRTCService {
);
}
// Video calls should use the loudspeaker, not the earpiece.
await setSpeakerphoneEnabled(true);
_isFullyInitialized = true;
if (!_initializationCompleter!.isCompleted) {

Loading…
Cancel
Save