public void TakeScreenshot()
 {
     ISN_PHPhotoLibrary.RequestAuthorization((status) => {
         if (status == ISN_PHAuthorizationStatus.Authorized)
         {
             ToggleCaputreScreenshot(true);
             ISN_UIImagePickerController.SaveScreenshotToCameraRoll((result) => {
                 if (result.IsSucceeded)
                 {
                     StartCoroutine(ShareableScreenshot());
                     Debug.Log("screenshot saved saved");
                 }
                 else
                 {
                     CaputreScreenshotResult(false);
                     Debug.Log("Error: " + result.Error.Message);
                 }
             });
         }
         else
         {
             CaputreScreenshotResult(false);
             Debug.Log("Permission denied");
         }
     });
 }
Esempio n. 2
0
 public override void Test()
 {
     SA_ScreenUtil.TakeScreenshot((tex) => {
         ISN_UIImagePickerController.SaveTextureToCameraRoll(tex, (result) => {
             SetAPIResult(result);
         });
     });
 }
Esempio n. 3
0
        internal static void CaptureMedia(int thumbnailSize, UM_MediaType type, ISN_UIImagePickerControllerSourceType source, Action <UM_MediaResult> callback)
        {
            ISN_UIImagePickerController picker = new ISN_UIImagePickerController();

            picker.SourceType = source;
            switch (type)
            {
            case UM_MediaType.Image:
                picker.MediaTypes = new List <string>()
                {
                    ISN_UIMediaType.IMAGE
                };
                break;

            case UM_MediaType.Video:
                picker.MediaTypes = new List <string>()
                {
                    ISN_UIMediaType.MOVIE
                };
                break;
            }

            picker.MaxImageSize           = thumbnailSize;
            picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG;
            picker.ImageCompressionRate   = 0.8f;

            UM_MediaResult pickResult;

            picker.Present((result) =>
            {
                if (result.IsSucceeded)
                {
                    UM_Media media = null;
                    switch (result.MediaType)
                    {
                    case ISN_UIMediaType.IMAGE:
                        media = new UM_Media(result.Image, result.ImageURL, UM_MediaType.Image);
                        break;

                    case ISN_UIMediaType.MOVIE:
                        Texture2D img = ISN_AVAssetImageGenerator.CopyCGImageAtTime(result.OriginalMediaURL, 0);
                        media         = new UM_Media(img, result.MediaURL, UM_MediaType.Video);
                        break;
                    }
                    pickResult = new UM_MediaResult(media);
                }
                else
                {
                    pickResult = new UM_MediaResult(result.Error);
                }

                callback.Invoke(pickResult);
            });
        }
    private void StartPicker(ISN_UIImagePickerControllerSourceType sourceType, string mediaType)
    {
        ISN_UIImagePickerController picker = new ISN_UIImagePickerController
        {
            SourceType = sourceType,
            MediaTypes = new List <string>()
            {
                mediaType
            },
            MaxImageSize           = 512,
            ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG,
            ImageCompressionRate   = 0.8f
        };

        picker.Present(DisplayResult);
    }
        public override void Test()
        {
            var picker = new ISN_UIImagePickerController();

            picker.SourceType = ISN_UIImagePickerControllerSourceType.Album;
            picker.MediaTypes = new List <string>()
            {
                ISN_UIMediaType.IMAGE
            };

            picker.MaxImageSize           = 512;
            picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG;
            picker.ImageCompressionRate   = 0.8f;

            picker.Present((result) => {
                if (result.IsSucceeded)
                {
                    if (!result.MediaType.Equals(ISN_UIMediaType.IMAGE))
                    {
                        SetResult(SA_TestResult.WithError("Wrong media type in callback"));
                        return;
                    }

                    if (result.Image == null)
                    {
                        SetResult(SA_TestResult.WithError("No image"));
                        return;
                    }

                    if (string.IsNullOrEmpty(result.ImageURL))
                    {
                        SetResult(SA_TestResult.WithError("No image"));
                        return;
                    }
                    TestVideo();
                }
                else
                {
                    SetAPIResult(result);
                }
            });
        }
 public void TakeScreenshot()
 {
     ISN_PHPhotoLibrary.RequestAuthorization((status) => {
         if (status == ISN_PHAuthorizationStatus.Authorized)
         {
             UIManager.GetComponent <UIManagerScript>().ToggleCaputreScreenshot(true);
             ISN_UIImagePickerController.SaveScreenshotToCameraRoll((result) => {
                 if (result.IsSucceeded)
                 {
                     StartCoroutine(ShareableScreenshot());
                 }
                 else
                 {
                     UIManager.GetComponent <UIManagerScript>().CaputreScreenshotResult(false);
                 }
             });
         }
         else
         {
             UIManager.GetComponent <UIManagerScript>().CaputreScreenshotResult(false);
         }
     });
 }
Esempio n. 7
0
    private void Start()
    {
        m_loadFromGallery.onClick.AddListener(() => {
            ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
            picker.SourceType = ISN_UIImagePickerControllerSourceType.Album;
            picker.MediaTypes = new List <string>()
            {
                ISN_UIMediaType.IMAGE
            };
            picker.MaxImageSize           = 512;
            picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG;
            picker.ImageCompressionRate   = 0.8f;

            picker.Present((result) => {
                if (result.IsSucceeded)
                {
                    if (result.Image != null)
                    {
                        Debug.Log("User selected an Image: " + result.Image);
                        m_image.sprite = result.Image.ToSprite();
                        m_go.GetComponent <Renderer>().material.mainTexture = result.Image;
                    }
                    else
                    {
                        Debug.Log("User selected a video at path: " + result.VideoPath);
                    }
                }
                else
                {
                    Debug.Log("Madia picker failed with reason: " + result.Error.Message);
                }
            });
        });


        m_loadFromCamera.onClick.AddListener(() => {
            ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
            picker.SourceType = ISN_UIImagePickerControllerSourceType.Camera;
            picker.MediaTypes = new List <string>()
            {
                ISN_UIMediaType.IMAGE
            };

            picker.Present((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("Image captured: " + result.Image);
                    m_image.sprite = result.Image.ToSprite();
                    m_go.GetComponent <Renderer>().material.mainTexture = result.Image;
                }
                else
                {
                    Debug.Log("Madia picker failed with reason: " + result.Error.Message);
                }
            });
        });


        m_saveToGallery.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((image) => {
                ISN_UIImagePickerController.SaveTextureToCameraRoll(image, (result) => {
                    if (result.IsSucceeded)
                    {
                        Debug.Log("Image saved");
                    }
                    else
                    {
                        Debug.Log("Error: " + result.Error.Message);
                    }
                });
            });
        });
    }
    private void Start()
    {
        m_loadFromGallery.onClick.AddListener(() => {
            /*
             *
             *      ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
             *      picker.SourceType = ISN_UIImagePickerControllerSourceType.Album;
             *      picker.MediaTypes = new List<string>() { ISN_UIMediaType.IMAGE};
             *      picker.MaxImageSize = 1024;
             *      picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG;
             *      picker.ImageCompressionRate = 0.8f;
             *      picker.Present((result) => {
             *          if (result.IsSucceeded) {
             *              Debug.Log("IMAGE local path: " + result.ImageURL);
             *             // mySprite = result.Image.ToSprite();
             *          } else {
             *             // canceled = true;
             *              Debug.Log("Media picker failed with reason: " + result.Error.Message);
             *          }
             *      });
             */


            ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
            picker.SourceType = ISN_UIImagePickerControllerSourceType.Album;
            picker.MediaTypes = new List <string>()
            {
                ISN_UIMediaType.MOVIE
            };


            picker.Present((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("MOVIE local path: " + result.MediaURL);

                    try{
                        byte[] movieBytes = File.ReadAllBytes(result.MediaURL);
                        Debug.Log("movie size bytes: " + movieBytes.Length);
                    } catch (System.Exception ex) {
                        Debug.Log(ex.Message);
                    }
                }
                else
                {
                    // canceled = true;
                    Debug.Log("Media picker failed with reason: " + result.Error.Message);
                }
            });


            //File

            /*
             *
             * ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
             * picker.SourceType = ISN_UIImagePickerControllerSourceType.Album;
             * picker.MediaTypes = new List<string>() { ISN_UIMediaType.IMAGE,  ISN_UIMediaType.MOVIE};
             * picker.MaxImageSize = 512;
             * picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG;
             * picker.ImageCompressionRate = 0.8f;
             *
             * picker.Present((result) => {
             * if (result.IsSucceeded) {
             *     switch(result.MediaType) {
             *         case ISN_UIMediaType.IMAGE:
             *             Debug.Log("IMAGE local path: " + result.ImageURL);
             *             m_image.sprite = result.Image.ToSprite();
             *             m_go.GetComponent<Renderer>().material.mainTexture = result.Image;
             *             break;
             *         case ISN_UIMediaType.MOVIE:
             *             Debug.Log("MOVIE local path: " + result.MediaURL);
             *             Texture2D image = ISN_AVAssetImageGenerator.CopyCGImageAtTime(result.MediaURL, 0);
             *             m_image.sprite = image.ToSprite();
             *             m_go.GetComponent<Renderer>().material.mainTexture = image;
             *             break;
             *     }
             * } else {
             *     Debug.Log("Madia picker failed with reason: " + result.Error.Message);
             * }
             * });
             */
        });



        m_loadFromCamera.onClick.AddListener(() => {
            ISN_UIImagePickerController picker = new ISN_UIImagePickerController();
            picker.SourceType = ISN_UIImagePickerControllerSourceType.Camera;
            picker.MediaTypes = new List <string>()
            {
                ISN_UIMediaType.IMAGE
            };

            picker.Present((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("Image captured: " + result.Image);
                    m_image.sprite = result.Image.ToSprite();
                    m_go.GetComponent <Renderer>().material.mainTexture = result.Image;
                }
                else
                {
                    Debug.Log("Madia picker failed with reason: " + result.Error.Message);
                }
            });
        });


        m_saveToGallery.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((image) => {
                ISN_UIImagePickerController.SaveTextureToCameraRoll(image, (result) => {
                    if (result.IsSucceeded)
                    {
                        Debug.Log("Image saved");
                    }
                    else
                    {
                        Debug.Log("Error: " + result.Error.Message);
                    }
                });
            });
        });
    }
Esempio n. 9
0
 public override void SaveImage(Texture2D image, string fileName, Action <SA_Result> callback)
 {
     ISN_UIImagePickerController.SaveTextureToCameraRoll(image, callback);
 }
    // Use this for initialization
    void Start()
    {
        ISN_NSBuildInfo buildInfo = ISN_NSBundle.BuildInfo;

        Debug.Log("AppVersion: " + buildInfo.AppVersion);
        Debug.Log("BuildNumber: " + buildInfo.BuildNumber);


        if (ISN_NSBundle.IsRunningInAppStoreEnvironment)
        {
            Debug.Log("This app was downloaded from an AppStore");
        }



        ISN_UIAlertController alert     = new ISN_UIAlertController("Hello", "Would you like to continue.", ISN_UIAlertControllerStyle.Alert);
        ISN_UIAlertAction     yesAction = new ISN_UIAlertAction("Yes", ISN_UIAlertActionStyle.Default, () => {
            //User said yes
        });

        //We can highlight button to show that
        //this option is preffered to be choosen
        yesAction.MakePreffered();

        ISN_UIAlertAction noAction = new ISN_UIAlertAction("No", ISN_UIAlertActionStyle.Default, () => {
            //User said no
        });

        alert.AddAction(yesAction);
        alert.AddAction(noAction);


        alert.Present();


        ISN_Preloader.LockScreen();
        ISN_Preloader.UnlockScreen();


        Debug.Log("Name:" + ISN_UIDevice.CurrentDevice.Name);
        Debug.Log("SystemName:" + ISN_UIDevice.CurrentDevice.SystemName);
        Debug.Log("SystemVersion:" + ISN_UIDevice.CurrentDevice.SystemVersion);
        Debug.Log("Model:" + ISN_UIDevice.CurrentDevice.Model);
        Debug.Log("LocalizedModel:" + ISN_UIDevice.CurrentDevice.LocalizedModel);
        Debug.Log("MajorIOSVersion:" + ISN_UIDevice.CurrentDevice.MajorIOSVersion);

        Debug.Log("UserInterfaceIdiom:" + ISN_UIDevice.CurrentDevice.UserInterfaceIdiom);
        Debug.Log("IdentifierForVendor:" + ISN_UIDevice.CurrentDevice.IdentifierForVendor);


        /*
         * ISN_UIImagePickerController.SaveScreenshotToCameraRoll((result) => {
         *  if (result.IsSucceeded) {
         *      Debug.Log("screenshot saved saved");
         *  } else {
         *      Debug.Log("Error: " + result.Error.Message);
         *  }
         * });
         *
         *
         *
         *
         *
         *
         * ISN_PHPhotoLibrary.RequestAuthorization((status) => {
         *  if(status == ISN_PHAuthorizationStatus.Authorized) {
         *      Debug.Log("Permission granted");
         *  } else {
         *      Debug.Log("Permission denied");
         *  }
         * });
         */

        ISN_PHAuthorizationStatus status;

        status = ISN_PHPhotoLibrary.AuthorizationStatus;
        Debug.Log("Photo Library Authorization Status: " + status);

        ISN_UIImagePickerController picker = new ISN_UIImagePickerController();

        picker.SourceType = ISN_UIImagePickerControllerSourceType.Camera;
        picker.MediaTypes = new List <string>()
        {
            ISN_UIMediaType.IMAGE
        };

        picker.Present((result) => {
            if (result.IsSucceeded)
            {
                Debug.Log("Image captured: " + result.Image);
            }
            else
            {
                Debug.Log("Madia picker failed with reason: " + result.Error.Message);
            }
        });

        ISN_RPScreenRecorder.StopRecording((result) => {
            if (result.IsSucceeded)
            {
                Debug.Log("Scrren recodring is started");
            }
            else
            {
                Debug.Log("User decalied screen recording request");
            }
        });

        bool isAvailable = ISN_RPScreenRecorder.IsAvailable;


        ISN_RPScreenRecorder.StopRecording((result) => {
            if (result.HasPreviewController)
            {
                result.PreviewController.Present((prevewResult) => {
                    if (prevewResult.IsSucceeded)
                    {
                        Debug.Log("User Saved video");
                        foreach (string activity in prevewResult.ActivityTypes)
                        {
                            Debug.Log("Video was shared to: " + activity);
                        }
                    }
                });
            }
        });

        ISN_RPScreenRecorder.DidChangeAvailability.AddListener(() => {
            Debug.Log("Replay Kit avalibility has chnaged:");
            Debug.Log("Replay Kit avaliable: " + ISN_RPScreenRecorder.IsAvailable);
        });


        ISN_RPScreenRecorder.DidStopRecording.AddListener((result) => {
            if (result.HasPreviewController)
            {
                result.PreviewController.Present((prevewResult) => {
                    if (prevewResult.IsSucceeded)
                    {
                        Debug.Log("User Saved video");
                        foreach (string activity in prevewResult.ActivityTypes)
                        {
                            Debug.Log("Video was shared to: " + activity);
                        }
                    }
                });
            }
        });



        /*
         *
         *
         * Texture2D myImage = GetImage();
         * ISN_UIImagePickerController.SaveTextureToCameraRoll(myImage, (result) => {
         *  if(result.IsSucceeded) {
         *      Debug.Log("Image saved");
         *  } else {
         *      Debug.Log("Error: " + result.Error.Message);
         *  }
         * });
         *
         *
         * var source = ISN_UIImagePickerControllerSourceType.PhotoLibrary;
         * bool isAvailable = ISN_UIImagePickerController.IsSourceTypeAvailable(source);
         *
         * var source = ISN_UIImagePickerControllerSourceType.Album;
         * List<string> availableMediaType = ISN_UIImagePickerController.GetAvailableMediaTypes(source);
         * foreach(var mediaType in availableMediaType) {
         *  Debug.Log(mediaType);
         * }
         */



        ISN_NSUbiquitousKeyValueStore.StoreDidChangeExternallyNotification.AddListener((changes) => {
            // get changes that might have happened while this
            // instance of your app wasn't running
        });
    }