Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Audio Route when switching with Bluetooth earphone in a Video call #294

Open
ArcherEmiya05 opened this issue Jul 27, 2022 · 4 comments

Comments

@ArcherEmiya05
Copy link

ArcherEmiya05 commented Jul 27, 2022

According to this documentation and this starting a video call automatically start with speaker phone and when an external audio device is removed like a Bluetooth earphone then the SDK sets the audio route as follows (in order of priority): setEnableSpeakerphone > setDefaultAudioRouteToSpeakerphone > the default audio route but that doesn't really happen. After removing/disconnecting the Bluetooth earphone the audio moves to earpiece. This also happens in a Voice call even if you set setDefaultAudioRouteToSpeakerphone to true. We are using 3.7.0.

We also tried to update the route during audio route change but setEnableSpeakerphone and setDefaultAudioRoutetoSpeakerphone does not work.

@Override
    public void onAudioRouteChanged(int routing) {
        super.onAudioRouteChanged(routing);

        switch (routing) {

            case Constants.AUDIO_ROUTE_EARPIECE: //Next move: Speaker
                speakerBtn.setAlpha(1f);
                speakerBtn.setEnabled(true);
                rtcEngine().setEnableSpeakerphone(false);
                rtcEngine().setDefaultAudioRoutetoSpeakerphone(false);
                speakerBtn.setImageResource(R.drawable.ic_speaker_on);
                break;
            case Constants.AUDIO_ROUTE_SPEAKERPHONE: //Next move Earpiece
                speakerBtn.setAlpha(1f);
                speakerBtn.setEnabled(true);
                rtcEngine().setEnableSpeakerphone(true);
                rtcEngine().setDefaultAudioRoutetoSpeakerphone(true);
                speakerBtn.setImageResource(R.drawable.ic_speaker_off);
                break;
            default:
                speakerBtn.setAlpha(0.3f);
                speakerBtn.setEnabled(false); // More icon for Headset Bluetooth, Headset with mic, Headset without mic, External speaker
                break;
                // See https://docs.agora.io/en/All/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#a61961c9f6681f1cd781527fed8fa649c
        }

    }
@ArcherEmiya05
Copy link
Author

Any help? This is really became a blocker on our development.

@ArcherEmiya05
Copy link
Author

Update:
This somewhat works fine a little bit.

 @Override
    public void onAudioRouteChanged(int routing) {
        Log.i("Agora Audio Route", "Changed");

        switch (routing){

            case Constants.AUDIO_ROUTE_SPEAKERPHONE:
                rtcEngine().setDefaultAudioRoutetoSpeakerphone(true); // This however sometimes does not work when switching back and forth with Bluetooth earphone
                rtcEngine().setEnableSpeakerphone(true); // This however sometimes does not work when switching back and forth with Bluetooth earphone
                break;
            case Constants.AUDIO_ROUTE_EARPIECE:
                rtcEngine().setDefaultAudioRoutetoSpeakerphone(false);
                rtcEngine().setEnableSpeakerphone(false);
                break;

        }

    }

It seems we are also need to call these line explicitly before rtcEngine().enableVideo() to work

                rtcEngine().setDefaultAudioRoutetoSpeakerphone(true); 
                rtcEngine().setEnableSpeakerphone(true);

@silversquall
Copy link

I am facing the same issue with agora_rtc_engine flutter version 5.3.1 and this has became a major blocker for our release.
@ArcherEmiya05 are you still facing this issue ?

@weileifrank
Copy link
Collaborator

@ArcherEmiya05 You can upgrade the SDK version (i.e 4.x.x) and refer to the examples for audio router in the below link :

https://github.com/AgoraIO/API-Examples/blob/main/Android/APIExample/app/src/main/java/io/agora/api/example/examples/basic/JoinChannelAudio.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants