public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initialize the class responsible for managing AV capture session and asset writer
            videoProcessor = new RosyWriterVideoProcessor();

            // Keep track of changes to the device orientation so we can update the video processor
            var notificationCenter = NSNotificationCenter.DefaultCenter;

            notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, DeviceOrientationDidChange);

            UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();

            // Setup and start the capture session
            videoProcessor.SetupAndStartCaptureSession();
            Console.WriteLine("Finished Setting up AV");

            notificationCenter.AddObserver(UIApplication.DidBecomeActiveNotification, On_ApplicationDidBecomeActive);

            oglView = new RosyWriterPreviewWindow(RectangleF.Empty);

            // Our interface is always in portrait
            oglView.Transform = videoProcessor.TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation.Portrait);

            RectangleF bounds = viewPreview.ConvertRectToView(viewPreview.Bounds, oglView);

            oglView.Bounds = bounds;
            oglView.Center = new PointF(viewPreview.Bounds.Size.Width / 2.0F, viewPreview.Bounds.Size.Height / 2.0F);

            viewPreview.AddSubview(oglView);

            Console.WriteLine("Added OGL View");

            // Set up labels
            shouldShowStats = true;

            frameRateLabel = LabelWithText(string.Empty, 10.0F);
            viewPreview.AddSubview(frameRateLabel);

            dimensionsLabel = LabelWithText(string.Empty, 54.0F);
            viewPreview.AddSubview(dimensionsLabel);

            typeLabel = LabelWithText(string.Empty, 90F);
            viewPreview.Add(typeLabel);

            // btnRecord Event Handler
            btnRecord.Clicked += On_ToggleRecording;

            // Video Processor Event Handlers
            videoProcessor.RecordingDidStart          += On_RecordingDidStart;
            videoProcessor.RecordingDidStop           += On_RecordingDidStop;
            videoProcessor.RecordingWillStart         += On_RecordingWillStart;
            videoProcessor.RecordingWillStop          += On_RecordingWillStop;
            videoProcessor.PixelBufferReadyForDisplay += On_PixelBufferReadyForDisplay;

            Console.WriteLine("Finished OnDidLoad");
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            statisticView.Layer.CornerRadius = 4f;

            // Initialize the class responsible for managing AV capture session and asset writer
            videoProcessor = new RosyWriterVideoProcessor();

            // Setup and start the capture session
            var isSupported = videoProcessor.SetupAndStartCaptureSession();

            if (isSupported)
            {
                // Our interface is always in portrait
                previewView.Transform = videoProcessor.TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation.Portrait);
                previewView.Bounds    = View.ConvertRectToView(View.Bounds, previewView);
                previewView.Center    = new CGPoint(View.Bounds.Size.Width / 2f, View.Bounds.Size.Height / 2f);

                UIApplication.Notifications.ObserveDidBecomeActive(OnApplicationDidBecomeActive);

                // Set up labels
                shouldShowStats = true;

                // Video Processor Event Handlers
                videoProcessor.RecordingDidStart          += OnRecordingDidStart;
                videoProcessor.RecordingDidStop           += OnRecordingDidStop;
                videoProcessor.RecordingWillStart         += OnRecordingWillStart;
                videoProcessor.RecordingWillStop          += OnRecordingWillStop;
                videoProcessor.PixelBufferReadyForDisplay += OnPixelBufferReadyForDisplay;
            }
            else
            {
                errorLabel.Hidden = false;

                previewView.Hidden   = true;
                recordButton.Enabled = false;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Initialize the class responsible for managing AV capture session and asset writer
            videoProcessor = new RosyWriterVideoProcessor ();

            // Keep track of changes to the device orientation so we can update the video processor
            var notificationCenter = NSNotificationCenter.DefaultCenter;
            notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, DeviceOrientationDidChange);

            UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications ();

            // Setup and start the capture session
            videoProcessor.SetupAndStartCaptureSession ();

            notificationCenter.AddObserver (UIApplication.DidBecomeActiveNotification, OnApplicationDidBecomeActive);

            oglView = new RosyWriterPreviewWindow(CGRect.Empty);

            // Our interface is always in portrait
            oglView.Transform = videoProcessor.TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation.Portrait);

            CGRect bounds = previewView.ConvertRectToView(previewView.Bounds, oglView);
            oglView.Bounds = bounds;
            oglView.Center = new CGPoint(previewView.Bounds.Size.Width / 2.0F, previewView.Bounds.Size.Height / 2.0F);

            previewView.AddSubview(oglView);

            // Set up labels
            shouldShowStats = true;

            frameRateLabel = LabelWithText (string.Empty, 10.0F);
            previewView.AddSubview (frameRateLabel);

            dimensionsLabel = LabelWithText (string.Empty, 54.0F);
            previewView.AddSubview (dimensionsLabel);

            typeLabel = LabelWithText (string.Empty, 90F);
            previewView.Add (typeLabel);

            // btnRecord Event Handler
            btnRecord.Clicked += OnToggleRecording;

            // Video Processor Event Handlers
            videoProcessor.RecordingDidStart += OnRecordingDidStart;
            videoProcessor.RecordingDidStop += OnRecordingDidStop;
            videoProcessor.RecordingWillStart += OnRecordingWillStart;
            videoProcessor.RecordingWillStop += OnRecordingWillStop;
            videoProcessor.PixelBufferReadyForDisplay += OnPixelBufferReadyForDisplay;
        }