libstreaming
libstreaming copied to clipboard
mute microphone in streaming
I need to disable audio microphone source with a button, and I've found in Session class:
/** You probably don't need to use that directly, use the {@link SessionBuilder}. */
void removeAudioTrack() {
if (mAudioStream != null) {
mAudioStream.stop();
mAudioStream = null;
}
}
I didn't find in SessionBuilder the method calling this removeAudioTrack()... Should I implement it by myself or there's another way to do the trick ?
+1
the following solution is finicky at best:
AudioManager myAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
@kmlx that didn't work for me. I can still hear the sound. AudioManager myAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); myAudioManager.setMicrophoneMute(true);
depends on the device. on nexus7 2013 works perfectly. same for others. but mostly samsung devices don't work.
I'm using:
mSession = SessionBuilder.getInstance() .setContext(getApplicationContext()) .setAudioEncoder(SessionBuilder.AUDIO_NONE) .setAudioQuality(new AudioQuality(8000,16000)) .setVideoEncoder(SessionBuilder.VIDEO_H264) .setSurfaceView(mSurfaceView) .setPreviewOrientation(0) .setCallback(this) .build();
after the session is stopped, so I can mute the audio in this way and restart the session...
and that should work, but the problem relies with muting the sound while in streaming. For example:
AudioManager myAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
myAudioManager.setMicrophoneMute(true);
this doesn't work on all devices/android versions. But it does work on some of them.
@nocturnalprelude Hello i am getting the audio issue will u plz help me how to fix it plzzz plzz