MediaRecorder failed when i stop the recording

后端 未结 2 1540
感情败类
感情败类 2020-12-10 00:43

I have this error. Can somebody please help me, I think it\'s something about touch listener... The error is happening when I release my finger.

04-25 20:07:         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 01:18

    Look at the documentation:

    Note that a RuntimeException is intentionally thrown to the application, if no valid audio/video data has been received when stop() is called. This happens if stop() is called immediately after start(). The failure lets the application take action accordingly to clean up the output file (delete the output file, for instance), since the output file is not properly constructed when this happens.

    In other words: Dalvik throws the exception on purpose. You have to handle it to clean up after your app. You'd have to handle it like this:

    private void stopRecording() {
        try {
            recorder.stop();
        } catch(RuntimeException stopException) {
            // handle cleanup here
        }
        camera.lock();
    }
    

提交回复
热议问题