case 1: I am working on VOIP project where users can talk using their android smartphones. case 2: The same time i also want to record the voice & video on a device and save it on local sd card.
The problem is i am not able to record voice in case 2. Case 1 works fine and users are able to talk to each other. for case 1 i set "audio source" like this
int audioSource = mSettings.isHandsetMode() ?
MediaRecorder.AudioSource.DEFAULT : MediaRecorder.AudioSource.MIC;
and in case 2 i am setting "audio source" like this:
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void initRecorder() {
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(DisplayUtils.width(this), DisplayUtils.height(this));
Random random=new Random();
filename=new File(Environment.getExternalStorageDirectory(), random.nextInt() + ".mp4").getAbsolutePath();
mMediaRecorder.setOutputFile(filename);
}
Here in "case 2" am not able to record voice & video. what could be the issue ?