According to the documentation, http://developer.android.com/reference/android/media/MediaRecorder.html#setMaxDuration(int)
the recording stops when the timer expires.
By stop, do they mean it calls internally recorder.stop() and then restores the state the app was in before calling recorder.start()?
I have found that I have to implement MediaRecorder.OnInfoListener and manually stop the recording at that point. Once that is done, the MediaRecorder goes back to the initial state and all of the normal setup has to be done again in order to start recording again.
public class VideoCapture extends Activity implements MediaRecorder.OnInfoListener {
public void startVideoRecording() {
// Normal MediaRecorder Setup
recorder.setMaxDuration(10000); // 10 seconds
recorder.setOnInfoListener(this);
}
public void onInfo(MediaRecorder mr, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
Log.v("VIDEOCAPTURE","Maximum Duration Reached");
mr.stop();
}
}
}
This is handled by OpenCore internally, and the state of the recorder after reaching max duration is uninitialized, as it called stop(). You have setup the recorder again to use it further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With