简体   繁体   中英

App does not connect audio to headphones Sinch App to App (Android)

I created App to App Android Sinch Application. When user on call without headphone its working on speaker but if user connect headphone its not automatically connecting to headphone instead of that i need to manually mute speaker and its connecting to headphone. Please check the code i done.

 private void enableSpeaker(boolean enable) { AudioController audioController = getSinchServiceInterface().getAudioController(); if (enable) audioController.enableSpeaker(); else audioController.disableSpeaker(); switchVolume.setImageDrawable(ContextCompat.getDrawable(this, isSpeaker ? R.drawable.ic_speaker : R.drawable.ic_speaker_off)); } private void setMuteUnmute() { AudioController audioController = getSinchServiceInterface().getAudioController(); if (isMute) { audioController.mute(); switchMic.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_mic_off)); } else { audioController.unmute(); switchMic.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_mic_on)); } }

I think you enabled Speaker in your onCallEstablished method.

Remove enableSpeaker() method from onCallEstablished method and add enableAutomaticAudioRouting() like below.

For more details check sinch documentation Here

@Override
public void onCallEstablished(Call call)
{
    AudioController audioController = getSinchServiceInterface().getAudioController();
    audioController.enableAutomaticAudioRouting(true, AudioController.UseSpeakerphone.SPEAKERPHONE_AUTO);        
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM