实际上我正在尝试使用mediarecorder录制语音通话。我的代码适用于某些设备,但像lenovo索尼一样,它不起作用。调用IOEXCEPTION
时出现mediarecorder.prepare()
错误。这是我的代码
{
cou = 1;
String nam = "/"+name+"("+cou+")"+".wav";
String voicefile = recordfolder + nam ;
File vf = new File(voicefile);
while (vf.exists()) {
cou = cou + 1;
nam = "/"+name+"("+cou+")"+".wav";
voicefile = recordfolder + nam ;
vf = new File(voicefile);
System.out.println("cou valuee"+cou);
}
System.out.println("cou value isssssss" + cou);
voicefile = recordfolder + nam ;
try {
mymediarecorder();
}
catch (Exception e {
System.out.println("error to run mediarecorder function");
}
try {
myAudioRecorder = new MediaRecorder();
myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
myAudioRecorder.setOutputFile(voicefile);
myAudioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
System.out.println("audio file setup done");
}
catch (Exception e)
{
System.out.println("now problem hereee");
}
try {
myAudioRecorder.prepare();
}
catch (IllegalStateException e) {
System.out.println("problem to prepare .wav");
}
catch (IOException e) {
System.out.println("problem to prepare .wav IOEXCEPTION ");
}
myAudioRecorder.start();
}