Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;

			}
		}
Exemplo n.º 3
0
        bool SetupCaptureSession()
        {
            // configure the capture session for low resolution, change this if your code
            // can cope with more data or volume
            session = new AVCaptureSession()
            {
                SessionPreset = AVCaptureSession.PresetMedium
            };


            AVCaptureDevice captureDevice = null;
            var             videoDevices  = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);

            foreach (AVCaptureDevice Device in videoDevices)
            {
                if (Device.Position == AVCaptureDevicePosition.Front)
                {
                    captureDevice = Device;
                    break;
                }
            }



            // create a device input and attach it to the session
            if (captureDevice == null)
            {
                captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
            }
            if (captureDevice == null)
            {
                return(false);
            }
            //Configure for 15 FPS. Note use of LockForConigfuration()/UnlockForConfiguration()
            NSError error = null;

            captureDevice.LockForConfiguration(out error);

            if (error != null)
            {
                captureDevice.UnlockForConfiguration();
                return(false);
            }
            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                captureDevice.ActiveVideoMinFrameDuration = new CMTime(1, 15);
            }

            captureDevice.UnlockForConfiguration();

            var input = AVCaptureDeviceInput.FromDevice(captureDevice);

            if (input == null)
            {
                return(false);
            }

            session.AddInput(input);

            // create a VideoDataOutput and add it to the sesion
            var output = new AVCaptureVideoDataOutput()
            {
                VideoSettings = new AVVideoSettings(CVPixelFormatType.CV32BGRA),
            };


            // configure the output
            queue          = new MonoTouch.CoreFoundation.DispatchQueue("myQueue");
            outputRecorder = new OutputRecorder(_state);
            output.SetSampleBufferDelegate(outputRecorder, queue);
            session.AddOutput(output);

            session.StartRunning();
            return(true);
        }
Exemplo n.º 4
0
			bool SetupCaptureSession ()
			{
				// configure the capture session for low resolution, change this if your code
				// can cope with more data or volume
				session = new AVCaptureSession () {
					SessionPreset = AVCaptureSession.PresetMedium
				};


				AVCaptureDevice captureDevice = null;
				var videoDevices = AVCaptureDevice.DevicesWithMediaType (AVMediaType.Video);
				foreach (AVCaptureDevice Device in videoDevices) {
					if (Device.Position == AVCaptureDevicePosition.Front)
					{
						captureDevice = Device;
						break;
					}
				}



				// create a device input and attach it to the session
				if(captureDevice==null){
					captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video);
				}
				if (captureDevice == null){
					return false;
				}
				//Configure for 15 FPS. Note use of LockForConigfuration()/UnlockForConfiguration()
				NSError error = null;
				captureDevice.LockForConfiguration(out error);

				if(error != null)
				{
					captureDevice.UnlockForConfiguration();
					return false;
				}
				if(UIDevice.CurrentDevice.CheckSystemVersion(7,0))
					captureDevice.ActiveVideoMinFrameDuration = new CMTime (1,15);

			captureDevice.UnlockForConfiguration();

			var input = AVCaptureDeviceInput.FromDevice (captureDevice);

				if (input == null){
					return false;
				}

				session.AddInput (input);

				// create a VideoDataOutput and add it to the sesion
				var output = new AVCaptureVideoDataOutput () {
					VideoSettings = new AVVideoSettings (CVPixelFormatType.CV32BGRA),
				};


				// configure the output
				queue = new MonoTouch.CoreFoundation.DispatchQueue ("myQueue");
				outputRecorder = new OutputRecorder (_state);
				output.SetSampleBufferDelegate (outputRecorder, queue);
				session.AddOutput (output);

				session.StartRunning ();
				return true;
			}