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屋!
查看全文