public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Disable UI until the session starts running
CameraButton.Enabled = false;
RecordButton.Enabled = false;
PhotoButton.Enabled = false;
CaptureModeControl.Enabled = false;
HUDButton.Enabled = false;
ManualHUD.Hidden = true;
ManualHUDPhotoView.Hidden = true;
ManualHUDFocusView.Hidden = true;
ManualHUDExposureView.Hidden = true;
ManualHUDWhiteBalanceView.Hidden = true;
ManualHUDLensStabilizationView.Hidden = true;
// Create the AVCaptureSession
Session = new AVCaptureSession ();
// Set up preview
PreviewView.Session = Session;
sessionQueue = new DispatchQueue ("session queue");
setupResult = SetupResult.Success;
// Check video authorization status. Video access is required and audio access is optional.
// If audio access is denied, audio is not recorded during movie recording.
CheckDeviceAuthorizationStatus ();
// Setup the capture session.
// In general it is not safe to mutate an AVCaptureSession or any of its inputs, outputs, or connections from multiple threads at the same time.
// Why not do all of this on the main queue?
// Because AVCaptureSession.StartRunning is a blocking call which can take a long time. We dispatch session setup to the sessionQueue
// so that the main queue isn't blocked, which keeps the UI responsive.
sessionQueue.DispatchAsync (ConfigureSession);
}