MediaRecorder failed when i stop the recording

后端 未结 2 1535
感情败类
感情败类 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:04

    I had a similar error -1007 when I was recording audio with AMR_WB, but it turned out that the problem was that I forgot to set sampling rate.

    mediaRecorder.setAudioSamplingRate(16000);
    
    0 讨论(0)
  • 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();
    }
    
    0 讨论(0)
提交回复
热议问题