我遇到了一個非常奇怪的行爲:有時我的媒體記錄器崩潰,出現錯誤「停止失敗」,有時它工作正常。是我的錯,還是系統的錯誤? 我不能得到什麼是錯的。Android媒體錄製器停止失敗
private void stopRecording(){
ticker.cancel();
ticker.purge();
recorder.stop();
startBtn.setText("Start");
recordInProcess = false;
markList = locWriteTask.getMarkArray();
mCamera.lock();
recorder.release();
}
private void startRecording(){
startBtn.setText("Stop");
recordInProcess = true;
recorder = new MediaRecorder();
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setPreviewDisplay(mSurfaceHolder.getSurface());
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setMaxDuration((int) 10000000);
recorder.setVideoSize(320, 240);
recorder.setVideoFrameRate(15);
recorder.setOutputFile(FULL_PATH_TO_LOCAL_FILE + counter + MP4);
try{
recorder.prepare();
} catch (Exception e){
finish();
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
ticker = new Timer();
locWriteTask = new WriteTimeLocationTimerTask(ll);
ticker.schedule(locWriteTask, 0, DELAY);
recorder.start();
}
我如何檢查MediaRecorder處於記錄狀態? – Kalpesh 2014-09-02 09:29:39
@Kalpesh MediaRecorder api不具備查詢其狀態的條款。 – Bhargav 2016-06-29 11:11:13