Android-录制视频时使麦克风静音 [英] Android - mute microphone while recording video
本文介绍了Android-录制视频时使麦克风静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在遵循与此类似的教程之后,我正在使用MediaRecorder类使用摄像机录制视频
I'm recording a video with the camera, using the MediaRecorder class, after following a tutorial similiar to this
我想在录音时能够使麦克风静音/取消静音. 那怎么可能?
And I want while recording, to be able to mute / unmute the microphone. How's that possible?
我正在开始设置音频源
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
但是,如果我想在某个时候录制无声怎么办?
But what if I want to record without sound at some point?
推荐答案
尝试以下代码:
private void setMicMuted(boolean state){
AudioManager myAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
// get the working mode and keep it
int workingAudioMode = myAudioManager.getMode();
myAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
// change mic state only if needed
if (myAudioManager.isMicrophoneMute() != state) {
myAudioManager.setMicrophoneMute(state);
}
// set back the original working mode
myAudioManager.setMode(workingAudioMode);
}
这篇关于Android-录制视频时使麦克风静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文