Android WebRTC implementaion - very low volume

前端 未结 1 1836
北海茫月
北海茫月 2021-01-23 23:46

I have implement an option of Video Conference on my application using the following example: https://github.com/androidthings/sample-videoRTC

basically is is working ve

相关标签:
1条回答
  • 2021-01-24 00:23

    After many check and investigation i have found the problem. i am answering it here if someone else will have the same problem.

    i have notice that the voice is not routed to the speaker but to the ear cap...so i add the bellow code to turn on the speaker and the problem has solved !

        audioManager = (AudioManager) this.activity.getSystemService(Context.AUDIO_SERVICE);
        audioManager.setSpeakerphoneOn(true);
        audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
    

    To answer the question where i put the code, i have actually add a new icon to give the user to switch between headset and speaker.

    here is the full code:

        toggleSpeakerHeadset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (speakerOn) {
                    setHeadsetOn();
                } else {
                    setSpeakerOn();
                }
            }
        });
    
    private void setSpeakerOn() {
        speakerOn = true;
        toggleSpeakerHeadset.setImageResource(R.drawable.headset);
        audioManager.setSpeakerphoneOn(true);
        audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
    }
    
    private void setHeadsetOn() {
        speakerOn = false;
        toggleSpeakerHeadset.setImageResource(R.drawable.speaker);
        audioManager.setSpeakerphoneOn(false);
        audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
    }
    
    0 讨论(0)
提交回复
热议问题