Example #1
0
        public void WillDisplayCameraCell(CameraCollectionViewCell cell)
        {
            SetupCameraCellIfNeeded(cell);

            if (cell is LivePhotoCameraCell liveCameraCell)
            {
                liveCameraCell.UpdateWithCameraMode(CaptureSettings.CameraMode);
            }

            if (_captureSession.PhotoCaptureSession != null)
            {
                //update live photos
                cell.UpdateLivePhotoStatus(_captureSession.PhotoCaptureSession.InProgressLivePhotoCapturesCount > 0,
                                           false);
            }

            //update video recording status
            var isRecordingVideo = _captureSession.VideoCaptureSession?.IsRecordingVideo ?? false;

            cell.UpdateRecordingVideoStatus(isRecordingVideo, false);

            //update authorization status if it's changed
            var status = AVCaptureDevice.GetAuthorizationStatus(AVAuthorizationMediaType.Video);

            if (cell.AuthorizationStatus != status)
            {
                cell.AuthorizationStatus = status;
            }

            //resume session only if not recording video
            if (!isRecordingVideo)
            {
                _captureSession.Resume();
            }
        }
Example #2
0
        public void DidEndDisplayingCameraCell(CameraCollectionViewCell cell)
        {
            var isRecordingVideo = _captureSession.VideoCaptureSession?.IsRecordingVideo ?? false;

            //suspend session only if not recording video, otherwise the recording would be stopped.
            if (isRecordingVideo == false)
            {
                _captureSession.Suspend();

                DispatchQueue.MainQueue.DispatchAsync(() => cell.BlurIfNeeded(false, null));
            }
        }
Example #3
0
        private void SetupCameraCellIfNeeded(CameraCollectionViewCell cell)
        {
            if (cell.Delegate != null)
            {
                return;
            }

            cell.Delegate                = _cameraCollectionViewCellDelegate;
            cell.PreviewView.Session     = _captureSession.Session;
            _captureSession.PreviewLayer = cell.PreviewView.PreviewLayer;

            var config = _captureSession.PresetConfiguration;

            if (config == SessionPresetConfiguration.Videos)
            {
                cell.IsVisualEffectViewUsedForBlurring = true;
            }
        }