예제 #1
0
        /// <summary>
        /// Capture an image from the device camera.
        /// </summary>
        /// <param name="maxSize">Max captured media thumbnail size that will be transferred to Unity</param>
        /// <param name="callback">Operation result callback.</param>
        public static void CaptureImage(int maxSize, Action <AN_CameraCaptureResult> callback)
        {
            var permissions = new[]
            {
                AMM_ManifestPermission.CAMERA,
                AMM_ManifestPermission.READ_EXTERNAL_STORAGE,
                AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE
            };

            AN_PermissionsUtility.TryToResolvePermission(
                new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE },
                (granted) => {
                AN_GalleryInternal.PickImageFromGallery(maxSize, AN_GalleryChooseType.CAPTURE_PICTURE, false, (result) => {
                    AN_CameraCaptureResult captureResult;

                    if (result.IsFailed)
                    {
                        captureResult = new AN_CameraCaptureResult(result.Error);
                    }
                    else
                    {
                        captureResult = new AN_CameraCaptureResult(result.Media[0]);
                    }
                    callback.Invoke(captureResult);
                });
            });
        }
예제 #2
0
        /// <summary>
        /// Starts pick media from a gallery flow.
        /// </summary>
        /// <param name="callback"></param>
        public void Show(Action <AN_GalleryPickResult> callback)
        {
            AN_PermissionsUtility.TryToResolvePermission(
                new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE },
                (granted) => {
                var type = AN_GalleryChooseType.PICK_PICTURE;
                if (m_types.Contains(AN_MediaType.Image) && m_types.Contains(AN_MediaType.Video))
                {
                    type = AN_GalleryChooseType.PICK_PICTURE_OR_VIDEO;
                }
                else
                {
                    if (m_types.Contains(AN_MediaType.Video))
                    {
                        type = AN_GalleryChooseType.PICK_VIDEO;
                    }
                }

                AN_GalleryInternal.PickImageFromGallery(m_maxSize, type, m_allowMultiSelect, callback);
            });
        }