Shu*_*jan 6 android voice-recording
我在Android棒棒糖和更高版本录制语音通话时遇到问题.通过这段代码,我能够录制我的声音,但无法记录其他人的声音.
public void startRecording() {
if (recording == false) {
Log.e("here", "--------Recorder_Sarted------" + fname);
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy");
int randomPIN = (int) (Math.random() * 9000) + 1000;
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
String file = Environment.getExternalStorageDirectory().toString();
String filepath = file + "/Aeris/Recording";
File dir = new File(filepath);
dir.mkdirs();
Log.e("here ", "----------------" + sdf.format(Calendar.getInstance().getTime()) + " " + fname + " " + type);
filepath += "/" + type + "-" + fname + "-" + sdf.format(Calendar.getInstance().getTime()) + "-" + randomPIN + ".3gp";
recorder.setOutputFile(filepath);
try {
recorder.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
recorder.start();
recording = true;
}
}
Run Code Online (Sandbox Code Playgroud)
这个代码在android lollipop版本下工作正常.请帮我解决这个问题
将音频源更改 VOICE_COMMUNICATION为MIC(麦克风)
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
Run Code Online (Sandbox Code Playgroud)
在Moto g2(Android 6.0)、lenovo (Android 5.0)上测试,运行良好。
| 归档时间: |
|
| 查看次数: |
911 次 |
| 最近记录: |