예제 #1
0
        Task <FileData> TakeMedia(bool p_isPhoto, CapturePhotoOptions p_options)
        {
            StatusBarStyle = UIApplication.SharedApplication.StatusBarStyle;
            var viewController = GetHostViewController();

            var ndelegate = new CaptureDelegate();
            var od        = Interlocked.CompareExchange(ref _pickerDelegate, ndelegate, null);

            if (od != null)
            {
                throw new InvalidOperationException("同一时间只可激活一次");
            }

            var view = new CaptureController(ndelegate);

            view.MediaTypes    = new[] { p_isPhoto ? "public.image" : "public.movie" };
            view.SourceType    = UIImagePickerControllerSourceType.Camera;
            view.CameraDevice  = p_options.UseFrontCamera ? UIImagePickerControllerCameraDevice.Front : UIImagePickerControllerCameraDevice.Rear;
            view.AllowsEditing = p_options.AllowCropping;
            if (p_isPhoto)
            {
                view.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo;
            }
            else if (p_options is CaptureVideoOptions voptions)
            {
                view.CameraCaptureMode    = UIImagePickerControllerCameraCaptureMode.Video;
                view.VideoQuality         = (voptions.VideoQuality == 0) ? UIImagePickerControllerQualityType.Low : UIImagePickerControllerQualityType.High;
                view.VideoMaximumDuration = voptions.DesiredLength.TotalSeconds;
            }
            viewController.PresentViewController(view, true, null);

            return(ndelegate.Task.ContinueWith(t =>
            {
                Dismiss(view);
                return t.Result;
            }));
        }
예제 #2
0
 internal CaptureController(CaptureDelegate mpDelegate)
 {
     base.Delegate = mpDelegate;
 }