How to know when MediaRecorder has finished writing data to file

前端 未结 6 961
迷失自我
迷失自我 2021-02-05 08:01

We\'re using MediaRecorder to record video to a file on the external storage using setOutputFile() before doing the actual recording.

Everything works fine, but the main

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 08:21

    Apparently there is no way to detect when the recording has stopped in Media player, but there is a stop() that you can override if you create a custom class that implements MediaRecorder. here I would do something like this:

    public class MyRecorder implements MediaRecorder {
        public boolean stopped;
    
        .... implement all the methods that MediaRecorder has making 
             sure to call super for each method.
    
        @Override
        public void myStop() {
            this.stopped = true;
            super.stop(); 
        }
    }
    

    Then you can access the boolean to see if it has stopped recording.

提交回复
热议问题