react-native-webrtc / react-native-incall-manager

Handling media-routes/sensors/events during a audio/video chat on React Native
ISC License
555 stars 193 forks source link

InCallManager.setForceSpeakerphoneOn doesnot work on Android #160

Closed zhangshaoju1987 closed 3 years ago

zhangshaoju1987 commented 3 years ago

setForceSpeakerphoneOn work well on IOS,but not work on Android

when I call it , I got them error info below: selectAudioDevice() Can not select EARPIECE from available [] selectAudioDevice() Can not select SPEAKER_PHONE from available []

Is there anything I missing/forget to do? I just use this api setForceSpeakerphoneOn only.

tatthangcntt commented 3 years ago

Today, I got the same issue. After checking the native log android. I realized the value of audioDevices is []. It mean: updateAudioDeviceState()has not be call. You can see that code will update the value of audioDevices

// Update the set of available audio devices. Set newAudioDevices = new HashSet<>(); // Update the existing audio device set. audioDevices = newAudioDevices;

So, I called IncallManager.start() When my app start. Then it works.

About the stop . You can call IncallManager.stop() to stop event, state .... But with my app, I just need to stop this when the application has been kill. Fortunately, IncallManager has done for us that in native code.

@Override public void onHostDestroy() { Log.d(TAG, "InCallManager:onDestroy()"); stopRingtone(); stopRingback(); stopBusytone(); stop(); }

rohitthakre commented 3 years ago
        InCallManager.setForceSpeakerphoneOn(0)

try with that

rohitthakre commented 3 years ago
        InCallManager.setForceSpeakerphoneOn(1)