我正在我的广播中录制一个音频文件,但我没有收到任何错误,但我的 recorder.stop() 从未被称为继承我的代码:
String file_name= "recording";
audiofile = File.createTempFile(file_name, ".3gp", sampleDir);
String path=Environment.getExternalStorageDirectory().getAbsolutePath();
//recorder = null;
int audioSource = MediaRecorder.AudioSource.VOICE_CALL;
recorder.setAudioSource(audioSource);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audiofile.getAbsolutePath());
recorder.prepare();
recorder.start();
我的停止功能包含:
public void stopRecord()throws IOException{
if(recorder!=null)
{
recorder.stop();
recorder.release();
recorder.reset();
Log.d(TAG, "recording stopped");
}
else
{
Log.d(TAG, "recording stopped error");
}
我在摘机阶段调用启动记录器并在空闲时停止记录器,但它进入空闲状态并且根本不调用停止。
case TelephonyManager.CALL_STATE_IDLE:
prev_state=state;
Log.d(TAG, "CALL_STATE_IDLE==>"+incoming_nr);
Log.d(TAG, "recording stopped"); // Executes till here and skips the below part
try {
stopRecord();
Log.d(TAG, "recording stopped");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d(TAG, "recording stopped");
我已授予所需的所有许可,请在此先感谢您