AVCaptureFileOutputRecordingDelegate FinishedRecording is not calling when StopRecording() done

I have a method to record video in Xamarin Forms , in iOS it is not working sometimes. Below is my code if I continuously tapping the Start record. and Stop record buttons sometimes video is not recording.
public void RecordVideo()
{
try
{
if (movieFileOutput.Recording == false)
{
var outputUrl = ApplicationDocumentsDirectory().Append($"fundsApp{new NSUuid()}", false).AppendPathExtension("mov");
var _delegate = new OutputVideoRecorder();
movieFileOutput.StartRecordingToOutputFile(outputUrl, _delegate);

            }
            else
            {      try
                    {
                         movieFileOutput.StopRecording(); **_// At this point the breakpoint stops. sometimes ,where it is not calling                      the AVCaptureFileOutputRecordingDelegate FinishedRecording is not calling_**
                    }
                    catch (Exception ex)
                    {

                    }

}
}
catch (Exception ex)
{

        }

    }

public class OutputVideoRecorder : AVCaptureFileOutputRecordingDelegate
{

        public override void FinishedRecording(AVCaptureFileOutput captureOutput, NSUrl outputFileUrl, NSObject[] connections, NSError error)
        {
            MainThread.BeginInvokeOnMainThread(() =>
            {

                //Sending this to server

            });

        }
    }
Sign In or Register to comment.