Ejemplo n.º 1
0
 private void DidFinishCaptureAction(VideoCaptureDelegate captureDelegate, NSUrl outputUrl)
 {
     DispatchQueue.MainQueue.DispatchAsync(() =>
     {
         if (captureDelegate?.IsBeingCancelled == true)
         {
             _videoRecordingDelegate?.DidCancelVideoRecording(this);
         }
         else
         {
             _videoRecordingDelegate?.DidFinishVideoRecording(this, outputUrl);
         }
     });
 }
Ejemplo n.º 2
0
        private void DidCaptureFail(VideoCaptureDelegate captureDelegate, NSError error, NSUrl outputUrl)
        {
            // we need to remove reference to the delegate so it can be deallocated
            _videoCaptureDelegate = null;

            DispatchQueue.MainQueue.DispatchAsync(() =>
            {
                if (captureDelegate.RecordingWasInterrupted)
                {
                    _videoRecordingDelegate?.DidInterruptVideoRecording(this, outputUrl, error);
                }
                else
                {
                    _videoRecordingDelegate?.DidFailVideoRecording(this, error);
                }
            });
        }
Ejemplo n.º 3
0
        public void StartVideoRecording(bool shouldSaveVideoToLibrary)
        {
            if (_videoFileOutput == null)
            {
                Console.WriteLine("capture session: trying to record a video but no movie file output is set");
                return;
            }

            _sessionQueue.DispatchAsync(() =>
            {
                // if already recording do nothing
                if (_videoFileOutput.Recording)
                {
                    Console.WriteLine(
                        "capture session: trying to record a video but there is one already being recorded");
                    return;
                }

                // start recording to a temporary file.
                var outputFileName = new NSUuid().AsString();

                var outputUrl = NSFileManager.DefaultManager.GetTemporaryDirectory().Append(outputFileName, false)
                                .AppendPathExtension("mov");

                var recordingDelegate = new VideoCaptureDelegate(DidStartCaptureAction,
                                                                 captureDelegate => DidFinishCaptureAction(captureDelegate, outputUrl),
                                                                 (captureDelegate, error) => DidCaptureFail(captureDelegate, error, outputUrl))
                {
                    ShouldSaveVideoToLibrary = shouldSaveVideoToLibrary
                };

                _videoFileOutput.StartRecordingToOutputFile(outputUrl, recordingDelegate);

                _videoCaptureDelegate = recordingDelegate;
            });
        }