AVCam.CameraViewController.ViewDidLoad C# (CSharp) Method

ViewDidLoad() public method

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

			// Disable UI. The UI is enabled if and only if the session starts running.
			CameraButton.Enabled = false;
			RecordButton.Enabled = false;
			PhotoButton.Enabled = false;
			LivePhotoModeButton.Enabled = false;
			CaptureModeControl.Enabled = false;

			// Setup the preview view.
			PreviewView.Session = session;

			// 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.
			switch (AVCaptureDevice.GetAuthorizationStatus (AVMediaType.Video)) {
				// The user has previously granted access to the camera.
				case AVAuthorizationStatus.Authorized:
					break;

				// The user has not yet been presented with the option to grant video access.
				// We suspend the session queue to delay session setup until the access request has completed to avoid
				// asking the user for audio access if video access is denied.
				// Note that audio access will be implicitly requested when we create an AVCaptureDeviceInput for audio during session setup.
				case AVAuthorizationStatus.NotDetermined:
					sessionQueue.Suspend ();
					AVCaptureDevice.RequestAccessForMediaType (AVMediaType.Video, granted => {
						if (!granted)
							setupResult = AVCamSetupResult.CameraNotAuthorized;
						sessionQueue.Resume ();
					});
					break;

				// The user has previously denied access.
				default:
					setupResult = AVCamSetupResult.CameraNotAuthorized;
					break;
			}

			// 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);
		}