I want to enable users to record a video for duration up to a max of 2 minutes in my app. I do provide the max duration for the video recording intent in my code but the recorder doesn't stop after that time. What do i need to do for it ?
Here's the code for recording the video using intent.
private void TakeAVideo()
{
Intent intent = new Intent(MediaStore.ActionVideoCapture);
RecorderFile._file = new File(RecorderFile._dir, String.Format("vm_movie_{0}.mp4", Guid.NewGuid()));
if (IsFrontCameraAvailable) {
intent.PutExtra ("android.intent.extras.CAMERA_FACING", 1);
} else {
intent.PutExtra ("android.intent.extras.CAMERA_FACING", 0);
}
intent.PutExtra (MediaStore.ExtraDurationLimit, 120000);
intent.PutExtra (MediaStore.ExtraVideoQuality, 0);
intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(RecorderFile._file));
StartActivityForResult(intent, 0);
}
Ok. I Figured it out. Basically when we use an intent
to capture a video we should pass No of Seconds for setting up maximum duration and when we record using MediaRecorder
then we should set the max duration in milliseconds.
for setting max duration using intent
intent.PutExtra (MediaStore.ExtraDurationLimit, yourDurationInSeconds);
for setting max duration using MediaRecorder
mediaRecorderObject.SetMaximumDuration(youDurationInMilliSeconds);