Ejemplo n.º 1
0
        private void PickMedia(int thumbnailSize, AN_MediaType type, Action <UM_MediaResult> callback)
        {
            var picker = new AN_MediaPicker(type);

            picker.AllowMultiSelect = false;
            picker.MaxSize          = thumbnailSize;

            picker.Show(result =>
            {
                UM_MediaResult pickResult;
                if (result.IsSucceeded)
                {
                    UM_MediaType um_type;
                    switch (type)
                    {
                    case AN_MediaType.Video:
                        um_type = UM_MediaType.Video;
                        break;

                    default:
                        um_type = UM_MediaType.Image;
                        break;
                    }
                    var media  = new UM_Media(result.Media[0].Thumbnail, result.Media[0].RawBytes, result.Media[0].Path, um_type);
                    pickResult = new UM_MediaResult(media);
                }
                else
                {
                    pickResult = new UM_MediaResult(result.Error);
                }

                callback.Invoke(pickResult);
            });
        }
        public override void Test()
        {
            AN_MediaPicker picker = new AN_MediaPicker(AN_MediaType.Video);

            picker.AllowMultiSelect = true;
            picker.MaxSize          = 256;

            picker.Show((result) => {
                if (result.IsSucceeded)
                {
                    foreach (var an_image in result.Media)
                    {
                        AN_Logger.Log("ImagePath: " + an_image.Path);
                        AN_Logger.Log("Captured image Color: " + an_image.Thumbnail.GetPixel(10, 10));
                        AN_Logger.Log("Captured image Color: " + an_image.Thumbnail.GetPixel(50, 50));
                        AN_Logger.Log("m_texture.width: " + an_image.Thumbnail.width + " height: " + an_image.Thumbnail.height);
                    }
                }

                SetAPIResult(result);
            });
        }
    private void Awake()
    {
        AddFitter(m_image.gameObject);
        AddFitter(m_sprite.gameObject);

        m_captureAdvanced.onClick.AddListener(() => {
            var maxSize = 1024;
            AN_Camera.CaptureImage(maxSize, (result) => {
                PrintCaptureResult(result);
            });
        });


        m_captureVideo.onClick.AddListener(() => {
            var maxSize = 1024;

            AN_Camera.CaptureVideo(maxSize, (result) => {
                PrintCaptureResult(result);
            });
        });



        m_getVideos.onClick.AddListener(() => {
            var picker = new AN_MediaPicker(AN_MediaType.Video);
            picker.AllowMultiSelect = true;
            picker.MaxSize          = 512;

            picker.Show((result) => {
                PrintPickerResult(result);
            });
        });


        m_getMixed.onClick.AddListener(() => {
            var picker = new AN_MediaPicker(AN_MediaType.Image, AN_MediaType.Video);
            picker.AllowMultiSelect = true;
            picker.MaxSize          = 512;

            picker.Show((result) => {
                PrintPickerResult(result);
            });
        });

        m_getPictures.onClick.AddListener(() => {
            var picker = new AN_MediaPicker(AN_MediaType.Image);

            // Defines if multiple images picker is allowed.
            // The default value is < c > false </ c >
            picker.AllowMultiSelect = true;

            // Max thumbnail size that will be transferred to the Unity side.
            // The thumbnail will be resized before it sent.
            // The default value is 512.
            picker.MaxSize = 512;

            // Starts pick media from a gallery flow.
            picker.Show((result) => {
                PrintPickerResult(result);
            });
        });



        m_saveScreenshot.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot(512, (screenshot) => {
                AN_Gallery.SaveImageToGallery(screenshot, "ExampleScreenshot", (result) => {
                    if (result.IsFailed)
                    {
                        AN_Logger.Log("Filed:  " + result.Error.Message);
                        return;
                    }

                    AN_Logger.Log("Screenshot has been saved to:  " + result.Path);
                });
            });
        });
    }