Ejemplo n.º 1
0
 public void PauseCaptureSession()
 {
     if (captureSession.Running)
     {
         captureSession.StopRunning();
     }
 }
Ejemplo n.º 2
0
        public Task StopStreamingAsync()
        {
            if (session != null && session.Running)
            {
                session.StopRunning();
            }

            return(Task.FromResult <object>(null));
        }
 void StopCaptureSession()
 {
     m_queue.DispatchAsync(delegate()
     {
         m_session.StopRunning();
     });
 }
Ejemplo n.º 4
0
 void DisableCameraView()
 {
     captureSession?.StopRunning();
     ReleaseCaptureSession();
     ReleaseCaptureDevice();
     ReleasePreviewLayer();
 }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void stopCaptureSession()
 {
     if (captureSession != null)
     {
         captureSession.StopRunning();
     }
 }
Ejemplo n.º 8
0
 public void StopScan()
 {
     if (null != session)
     {
         session.StopRunning();
     }
 }
Ejemplo n.º 9
0
		public void StopScanning()
		{
			if (stopped)
				return;

			Console.WriteLine("Stopping...");

			//Try removing all existing outputs prior to closing the session
			try
			{
				while (session.Outputs.Length > 0)
					session.RemoveOutput (session.Outputs [0]);
			}
			catch { }

			//Try to remove all existing inputs prior to closing the session
			try
			{
				while (session.Inputs.Length > 0)
					session.RemoveInput (session.Inputs [0]);
			}
			catch { }

			if (session.Running)
				session.StopRunning();

			stopped = true;
		}
Ejemplo n.º 10
0
 public void StopPreview()
 {
     if (captureSession.Running)
     {
         captureSession.StopRunning();
     }
     IsPreviewing = false;
 }
Ejemplo n.º 11
0
 public void stopCaptureSession()
 {
     if (captureSession != null)
     {
         captureSession.StopRunning();
     }
     _stopFollowingDeviceOrientation();
 }
Ejemplo n.º 12
0
            public override void ViewWillDisappear(bool animated)
            {
                base.ViewWillDisappear(animated);

                if (_captureSession != null)
                {
                    _captureSession.StopRunning();
                }
            }
Ejemplo n.º 13
0
        private void EndSession()
        {
            captureSession.StopRunning();

            foreach (var i in captureSession.Inputs)
            {
                captureSession.RemoveInput(i);
            }
        }
        public override void ViewWillDisappear(bool animated)
        {
            if (_captureSession != null && _captureSession.Running)
            {
                _captureSession.StopRunning();
            }

            NavigationController.SetNavigationBarHidden(false, false);
            base.ViewWillDisappear(animated);
        }
        private void StopRecording()
        {
            timer.Invalidate();
            timer.Dispose();
            timer = null;

            output.StopRecording();

            weAreRecording = false;
            nfloat width  = this.View.Frame.Size.Width;
            nfloat height = this.View.Frame.Size.Height;


            session.StopRunning();
            btnStartRecording.RemoveFromSuperview();
            btnCancelPage.RemoveFromSuperview();

            this.View.AddSubview(activityIndicator);
            activityIndicator.StartAnimating();
        }
Ejemplo n.º 16
0
        public void StopCapture()
        {
            if (session != null)
            {
                StopHandlingFrames();
                session.StopRunning();
                session.Dispose();
            }

            isCapturing = false;
        }
Ejemplo n.º 17
0
 public override void ViewDidDisappear(bool animated)
 {
     sessionQueue.DispatchAsync(() => {
         if (setupResult == AVCamSetupResult.Success)
         {
             session.StopRunning();
             sessionRunning = session.Running;
             RemoveObservers();
         }
     });
     base.ViewDidDisappear(animated);
 }
Ejemplo n.º 18
0
        public override void ViewWillDisappear(bool animated)
        {
            session.StopRunning();
            this.btnStartRecording.TouchUpInside -= startStopPushed;

            foreach (var view in this.View.Subviews)
            {
                view.RemoveFromSuperview();
            }


            base.ViewWillDisappear(animated);
        }
Ejemplo n.º 19
0
        public void StopScanning()
        {
            if (overlayView != null)
            {
                if (overlayView is ZXingDefaultOverlayView)
                {
                    (overlayView as ZXingDefaultOverlayView).Destroy();
                }

                overlayView = null;
            }

            if (stopped)
            {
                return;
            }

            Console.WriteLine("Stopping...");

            if (outputRecorder != null)
            {
                outputRecorder.CancelTokenSource.Cancel();
            }

            //Try removing all existing outputs prior to closing the session
            try
            {
                while (session.Outputs.Length > 0)
                {
                    session.RemoveOutput(session.Outputs [0]);
                }
            }
            catch { }

            //Try to remove all existing inputs prior to closing the session
            try
            {
                while (session.Inputs.Length > 0)
                {
                    session.RemoveInput(session.Inputs [0]);
                }
            }
            catch { }

            if (session.Running)
            {
                session.StopRunning();
            }

            stopped = true;
        }
Ejemplo n.º 20
0
 private void IsScannerActive(PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(barcodeScanner.IsScannerActive))
     {
         if (barcodeScanner.IsScannerActive)
         {
             session.StartRunning();
         }
         else
         {
             session.StopRunning();
         }
     }
 }
        public void StopPreviewing(object sender, EventArgs e)
        {
            if (XamRecorder.IsRecording)
            {
                throw new Exception("You can't stop previewing while you're recording.");
            }

            if (XamRecorder.IsPreviewing)
            {
                session.StopRunning();

                XamRecorder.IsPreviewing = false;
            }
        }
Ejemplo n.º 22
0
        void Initialize()
        {
            Configuration.IsScanning = true;
            SizeChange();
            CaptureSession = new AVCaptureSession();
            CaptureSession.BeginConfiguration();
            this.Frame   = new CGRect(0f, 0f, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Width);
            previewLayer = new AVCaptureVideoPreviewLayer(CaptureSession)
            {
                Frame        = new CGRect(0f, 0f, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Width),
                VideoGravity = AVLayerVideoGravity.ResizeAspectFill,
            };
            setPreviewOrientation();
            var videoDevices   = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
            var cameraPosition = AVCaptureDevicePosition.Back;
            //var cameraPosition = (cameraOptions == CameraOptions.Front) ? AVCaptureDevicePosition.Front : AVCaptureDevicePosition.Back;
            var device = videoDevices.FirstOrDefault(d => d.Position == cameraPosition);

            if (device == null)
            {
                return;
            }

            NSError error;
            var     input = new AVCaptureDeviceInput(device, out error);

            CaptureSession.AddInput(input);
            CaptureSession.SessionPreset = AVFoundation.AVCaptureSession.Preset640x480;
            Layer.AddSublayer(previewLayer);

            CaptureSession.CommitConfiguration();
            CaptureSession.StartRunning();

            VideoDataOutput = new AVCaptureVideoDataOutput();
            VideoDataOutput.AlwaysDiscardsLateVideoFrames = true;
            VideoDataOutput.WeakVideoSettings             = new CVPixelBufferAttributes {
                PixelFormatType = CVPixelFormatType.CV32BGRA
            }.Dictionary;


            captureVideoDelegate             = new CaptureVideoDelegate();
            captureVideoDelegate.OnDetected += (list) =>
            {
                this.OnDetected?.Invoke(list);
                CaptureSession.StopRunning();
            };
            VideoDataOutput.SetSampleBufferDelegateQueue(captureVideoDelegate, CoreFoundation.DispatchQueue.MainQueue);

            CaptureSession.AddOutput(VideoDataOutput);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Stops the and dispose.
        /// </summary>
        public void StopAndDispose()
        {
            if (_device != null)
            {
                // if flash is on turn off
                if (_device.TorchMode == AVCaptureTorchMode.On)
                {
                    SwitchFlash(false);
                }
            }

            _captureSession.StopRunning();
            // dispose output elements
            _input.Dispose();
            _output.Dispose();
        }
        public void StopScanning()
        {
            if (stopped)
            {
                return;
            }

            Console.WriteLine("Stopping...");

            if (session.Running)
            {
                session.StopRunning();
            }

            stopped = true;
        }
        // This function captures a photo
        public async void CapturePhoto()
        {
            var videoConnection = stillImageOutput.ConnectionFromMediaType(AVMediaType.Video);
            var sampleBuffer    = await stillImageOutput.CaptureStillImageTaskAsync(videoConnection);

            var jpegImageAsNsData = AVCaptureStillImageOutput.JpegStillToNSData(sampleBuffer);
            var image             = new UIImage(jpegImageAsNsData);

            this.image = image;

            captureSession.StopRunning();

            retakePictureClick = true;
            var normalAttributedTitle = new NSAttributedString("Retake Picture", foregroundColor: UIColor.White);

            takePhotoButton.SetAttributedTitle(normalAttributedTitle, UIControlState.Normal);
        }
 private void StartSession(bool start)
 {
     try
     {
         if (start)
         {
             _AVSession?.StartRunning();
         }
         else
         {
             _AVSession?.StopRunning();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("IOS_SCAN | error StartCamera to " + start, ex);
     }
 }
Ejemplo n.º 27
0
        public void StopScanning()
        {
            if (_stopped)
            {
                return;
            }

            Console.WriteLine("Stopping...");

            _outputRecorder?.CancelTokenSource.Cancel();

            //Try removing all existing outputs prior to closing the session
            try
            {
                while (_session.Outputs.Length > 0)
                {
                    _session.RemoveOutput(_session.Outputs[0]);
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message);
            }

            //Try to remove all existing inputs prior to closing the session
            try
            {
                while (_session.Inputs.Length > 0)
                {
                    _session.RemoveInput(_session.Inputs[0]);
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message);
            }

            if (_session.Running)
            {
                _session.StopRunning();
            }

            _stopped = true;
        }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
        public void StopCapture()
        {
            if (isCapturing == false)
            {
                return;
            }

            isCapturing = false;

            // stop recording
            if (shouldRecord)
            {
                stopMovieWriter();
            }

            // stop the capture session
            session.StopRunning();

            unsubscribeDelegateEvents();
        }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 31
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			session = new AVCaptureSession ();

			var camera = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
			var input = AVCaptureDeviceInput.FromDevice(camera);
			session.AddInput(input);

			output = new AVCaptureMetadataOutput();
			var metadataDelegate = new MetadataOutputDelegate();
			output.SetDelegate(metadataDelegate, DispatchQueue.MainQueue);
			session.AddOutput(output);

			output.MetadataObjectTypes = new NSString[] {
				AVMetadataObject.TypeQRCode,
				AVMetadataObject.TypeEAN13Code
			};

			var previewLayer = new AVCaptureVideoPreviewLayer(session);
			//var view = new ContentView(UIColor.LightGray, previewLayer, metadataDelegate);

			previewLayer.MasksToBounds = true;
			previewLayer.VideoGravity = AVCaptureVideoPreviewLayer.GravityResizeAspectFill;
			previewLayer.Frame = UIScreen.MainScreen.Bounds;
			this.View.Layer.AddSublayer(previewLayer);

			metadataDelegate.MetadataFound += (s, e) => {
				session.StopRunning();
				new UIAlertView("Scanned!",e.StringValue, null ,"OK",null).Show();
			};

			session.StartRunning();

		}