I am facing the issue in recording the audio for calls .
Initially i recorded the audio by using the Mic it records audio but most of the audio is not recorded ,it creates an empty audio file. So that i switched to record the voice calls by using mediaRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
in this all voice calls are recorded successfully but this VOICE_CALL is supported till kitkat device . Most of them answered record the audio calls through MICROPHONE.
try {
f1 = File.createTempFile("Sound", ".mp3", dir);
} catch (IOException e) {
e.printStackTrace();
}
fileName = f1.getName();
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setOutputFile(f1.getAbsolutePath());
try {
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
recordstarted = true;
The above is recording through the VOICE_CALLS
The below code is for recording by MIC
try {
f1 = File.createTempFile("Sound", ".mp3", dir);
} catch (IOException e) {
e.printStackTrace();
}
fileName = f1.getName();
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setOutputFile(f1.getAbsolutePath());
try {
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
recordstarted = true;
Please help me how to record by MIC. While recording by mic it creates the empty file , when i played that file the error shown as "This type of audio files are not supported".