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 issue is that as soon as the recording is done, we want to start playing the recorded video back in a VideoView.
How to know when the file is ready to be read and played back?
The
FileObserverclass suits your needs perfectly. Here is the documentation. It’s easy to use. When a observed file is closed after writing, theonEventcallback is called withCLOSE_WRITEas the parameter.Don’t forget to call
stopWatching().