protected override void Dispose(bool disposing) { if (captureDeviceInput != null && captureSession != null) { captureSession.RemoveInput(captureDeviceInput); } if (captureDeviceInput != null) { captureDeviceInput.Dispose(); captureDeviceInput = null; } if (captureSession != null) { captureSession.StopRunning(); captureSession.Dispose(); captureSession = null; } if (stillImageOutput != null) { stillImageOutput.Dispose(); stillImageOutput = null; } base.Dispose(disposing); }
/// <summary> /// Stops the and tears down the capture session. /// </summary> public void StopAndTearDownCaptureSession() { if (captureSession != null) { if (captureSession.Running) { captureSession.StopRunning(); } NSNotificationCenter.DefaultCenter.RemoveObserver(this, AVCaptureSession.DidStopRunningNotification, captureSession); captureSession.Dispose(); captureSession = null; } if (previewBufferQueue != null) { previewBufferQueue.Dispose(); previewBufferQueue = null; } if (movieWritingQueue != null) { movieWritingQueue.Dispose(); movieWritingQueue = null; } }
void UserKnocked() { _state.didKnock = true; if (_state.CountDown > 0 && _state.CountDown < 5 && _state.PublishToTwitter == false) { _state.PublishToTwitter = true; session.StopRunning(); session.Dispose(); session = null; outputRecorder.Dispose(); outputRecorder = null; queue.Dispose(); queue = null; //Stop Both Timers AudioLoop.Invalidate(); timer.Invalidate(); //Stop Recording StopRecording(); //Start up Resording NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(10), AudioReset); NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(1), PostToTwitter); _state.PublishToTwitter = true; _state.TopLabel.Text = ""; _state.BottomLabel.Text = "Posted to Twitter!"; imgYouRock.Hidden = false; } }
protected override void Dispose(bool disposing) { captureSession.Dispose(); captureDeviceInput.Dispose(); stillImageOutput.Dispose(); base.Dispose(disposing); }
/// <summary> /// Cleanup the Resources. /// </summary> /// <param name="disposing">Is Disposing</param> protected override void Dispose(bool disposing) { captureSession?.Dispose(); videoDeviceInput?.Dispose(); videoDataOutput.Dispose(); base.Dispose(disposing); }
protected override void Dispose(bool disposing) { //remove rotation notifications NSNotificationCenter.DefaultCenter.RemoveObserver(rotationNotifation); session.Dispose(); base.Dispose(disposing); }
void ReleaseCaptureSession() { if (captureSession == null) { return; } captureSession.Dispose(); captureSession = null; }
public void StopCapture() { if (session != null) { StopHandlingFrames(); session.StopRunning(); session.Dispose(); } isCapturing = false; }
protected override void Dispose(bool disposing) { if (disposing) { if (captureSession.Running) { captureSession.StopRunning(); } isDisposing = true; videoPreviewLayer.Dispose(); captureDeviceInput.Dispose(); tesseract.Dispose(); targetOverlayView.Dispose(); captureSession.Dispose(); } base.Dispose(disposing); }
void HideCameraPreview() { if (captureSession != null) { captureSession.StopRunning(); captureSession.RemoveOutput(stillImageOutput); captureSession.Dispose(); captureSession = null; } if (stillImageOutput != null) { stillImageOutput.Dispose(); stillImageOutput = null; } captureButton.Hidden = true; cancelButton.Hidden = true; }
protected override void Dispose(bool disposing) { if (disposing) { RemoveObservers(); if (_session != null) { if (_session.Running) { _session.StopRunning(); } PreviewLayer.Session = null; if (_videoDeviceInput != null) { _session.RemoveInput(_videoDeviceInput); _videoDeviceInput.Dispose(); _videoDeviceInput = null; } if (_movieFileOutput != null) { _session.RemoveOutput(_movieFileOutput); _movieFileOutput.Dispose(); _movieFileOutput = null; } if (_stillImageOutput != null) { _session.RemoveOutput(_stillImageOutput); _stillImageOutput.Dispose(); _stillImageOutput = null; } _session.Dispose(); } } base.Dispose(disposing); }
public override void ViewDidUnload() { base.ViewDidUnload(); try { cancellationTokenSource.Cancel(); cancellationTokenSource.Dispose(); } catch (Exception) {} try { captureDeviceInput.Dispose(); } catch (Exception) { } try { videoDataOutput.Dispose(); } catch (Exception) { } try { captureSession.StopRunning(); } catch (Exception) { } try { captureSession.Dispose(); } catch (Exception) { } }
public void StopCaptureSession() { session.StopRunning(); session.Dispose(); session = null; }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); weAreRecording = false; btnStartRecording = UIButton.FromType(UIButtonType.Custom); btnStartRecording.Frame = new RectangleF(100, 100, 60, 50); btnStartRecording.SetImage(UIImage.FromFile("captureButton.png"), UIControlState.Normal); btnStartRecording.SetTitle("Start Recording", UIControlState.Normal); var screenSize = UIScreen.MainScreen.Bounds; var screenWidth = screenSize.Width; var screenHeight = screenSize.Height; activityIndicator = new UIActivityIndicatorView(); activityIndicator.Frame = new RectangleF(100, 100, 60, 50); activityIndicator.Center = new CGPoint(screenWidth / 2, screenHeight / 2); btnStartRecording.Center = new CGPoint(screenWidth / 2, screenHeight - 40); //Set up session session = new AVCaptureSession(); btnCancelPage = UIButton.FromType(UIButtonType.InfoLight); btnCancelPage.Frame = new RectangleF(200, 200, 160, 150); btnCancelPage.SetImage(UIImage.FromFile("icon_closemap.png"), UIControlState.Normal); btnCancelPage.Center = new CGPoint(15, 30); //Set up inputs and add them to the session //this will only work if using a physical device! Console.WriteLine("getting device inputs"); try { //add video capture device device = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video); input = AVCaptureDeviceInput.FromDevice(device); session.AddInput(input); //add audio capture device audioDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Audio); audioInput = AVCaptureDeviceInput.FromDevice(audioDevice); session.AddInput(audioInput); } catch (Exception ex) { //show the label error. This will always show when running in simulator instead of physical device. //lblError.Hidden = false; return; } //Set up preview layer (shows what the input device sees) Console.WriteLine("setting up preview layer"); previewlayer = new AVCaptureVideoPreviewLayer(session); previewlayer.Frame = this.View.Bounds; //this code makes UI controls sit on top of the preview layer! Allows you to just place the controls in interface builder cameraView = new UIView(); cameraView.Layer.AddSublayer(previewlayer); this.View.AddSubview(cameraView); this.View.SendSubviewToBack(cameraView); Console.WriteLine("Configuring output"); output = new AVCaptureMovieFileOutput(); long totalSeconds = 10000; Int32 preferredTimeScale = 30; CMTime maxDuration = new CMTime(totalSeconds, preferredTimeScale); output.MinFreeDiskSpaceLimit = 1024 * 1024; output.MaxRecordedDuration = maxDuration; if (session.CanAddOutput(output)) { session.AddOutput(output); } session.SessionPreset = AVCaptureSession.Preset640x480; Console.WriteLine("About to start running session"); session.StartRunning(); //toggle recording button was pushed. btnStartRecording.TouchUpInside += startStopPushed; btnCancelPage.TouchUpInside += (s, e) => { (Element as CameraPage).Navigation.PopAsync(); if (session.Running == true) { session.StopRunning(); } //session = null; session.RemoveInput(input); session.RemoveInput(audioInput); session.Dispose(); DismissViewController(true, null); }; View.AddSubview(btnCancelPage); View.AddSubview(btnStartRecording); timerLabel = new UILabel(new RectangleF(50, 50, 50, 50)) { TextColor = UIColor.White }; timerLabel.Text = "00:" + videoLength; timerLabel.Center = new CGPoint(screenWidth / 2, 30); timerLabel.TextColor = UIColor.White; View.AddSubview(timerLabel); }