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

enableAudio() method in NBMWebRTCPeer.java doesn't work. #4

Open
anaxdev opened this issue Jul 18, 2017 · 3 comments
Open

enableAudio() method in NBMWebRTCPeer.java doesn't work. #4

anaxdev opened this issue Jul 18, 2017 · 3 comments

Comments

@anaxdev
Copy link

anaxdev commented Jul 18, 2017

Hello.
I am going to implement the video/audio toggle feature. I am using enableVideo()/enableAudio() methods in NBMWebRTCPeer.java class.
Video toggle feature works fine but audio toggle feature doesn't work.
So I looked at the code and I found that enableAudio() method is empty.

    /**
     * Enable or disable audio
     * @param enable If true then audio will be enabled, if false then audio will be disabled
     */
    @SuppressWarnings("unused")
    public void enableAudio(boolean enable){

    }

Isn't there any other method to enable/disable the audio?

@vikoo
Copy link

vikoo commented Oct 31, 2017

you can use the following method to enable and disable audio.
enableAudio() method is not been in SDK.

 private boolean isMute = false;
 public void onMute(View view) {
    if(nbmWebRTCPeer != null) {
        AudioManager myAudioManager =
                       (AudioManager)getSystemService(Context.AUDIO_SERVICE);

        // get the working mode and keep it
        int workingAudioMode = myAudioManager.getMode();

        myAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

       
        myAudioManager.setMicrophoneMute(!isMute);
        isMute = !isMute;

        // set back the original working mode
        myAudioManager.setMode(workingAudioMode);
    }
}

@vikoo
Copy link

vikoo commented Oct 31, 2017

For speaker and on-call functionality. you can use the following method.

 public void onSpeakerClick(View view) {
    if(nbmWebRTCPeer != null) {
        AudioManager myAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);

        // get the working mode and keep it
        int workingAudioMode = myAudioManager.getMode();

        myAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

  
        myAudioManager.setSpeakerphoneOn(!isSpeaker);
        isSpeaker = !isSpeaker;

        // set back the original working mode
        myAudioManager.setMode(workingAudioMode);
    }
}

@anaxdev
Copy link
Author

anaxdev commented Oct 31, 2017

@vikoo Thank you for your information.

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

2 participants