Call Recorder正在大多数设备上录制,但没有在三星盛大上工作。意味着记录在传入或传出时开始并记录来自所选源(麦克风等)的声音,但是进一步的设备将停止记录声音(可能是记录器未在通话中从该源获取数据的原因(Android的用户)隐私问题))。
我已经尝试过AudioRecord和MediaRecorder,但问题仍未解决。
private MediaRecorder recorder = null;
recorder.setAudioSource(1);
recorder.setOutputFormat(1);
recorder.setAudioEncoder(1);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
我也尝试过audiorecord,但它不适合这个问题。
答案 0 :(得分:0)
我会发一个问题代码。这段代码在我的应用程序中完美运行
public void onStart(Intent intent,int startId){
mSampleFile = null;
if (mSampleFile == null) {
String newFolder = "/Recording";
String extStorageDirectory = Environment
.getExternalStorageDirectory().toString();
File myNewFolder = new File(extStorageDirectory + newFolder);
if (!myNewFolder.exists()) {
myNewFolder.mkdir();
}
try {
if (myNewFolder != null) {
mSampleFile = File.createTempFile(SAMPLE_PREFIX,
SAMPLE_EXTENSION, myNewFolder);
}
} catch (IOException e) {
}
}
if (mSampleFile != null) {
SharedPreferences mysharedprefs8 = getSharedPreferences(mypref32,
MODE_MULTI_PROCESS);
String status = mysharedprefs8.getString("pass", "AMR_NB");
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
if (status.equalsIgnoreCase("AMR")) {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
} else if (status.equalsIgnoreCase("MPEG")) {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
} else if (status.equalsIgnoreCase("3GPP")) {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
} else {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
}
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
} catch (IllegalStateException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
mRecorder.setMaxDuration(600000);
try {
mRecorder.prepare();
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mRecorder.start();
mRecorder.setOnInfoListener(new OnInfoListener() {
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
// TODO Auto-generated method stub
try {
mRecorder.stop();
mRecorder.reset();
mRecorder.release();
} catch (Exception e) {
}
}
});
}