Exemplo n.º 1
0
    private static void SaveToGalleryInternal(string path, string album, bool isImage, MediaSaveCallback callback)
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        AJC.CallStatic("MediaScanFile", Context, path);

        if (callback != null)
        {
            callback(null);
        }

        Debug.Log("Saving to gallery: " + path);
#elif !UNITY_EDITOR && UNITY_IOS
        NGMediaSaveCallbackiOS.Initialize(callback);
        if (isImage)
        {
            _NativeGallery_ImageWriteToAlbum(path, album);
        }
        else
        {
            _NativeGallery_VideoWriteToAlbum(path, album);
        }

        Debug.Log("Saving to Pictures: " + Path.GetFileName(path));
#else
        if (callback != null)
        {
            callback(null);
        }
#endif
    }
Exemplo n.º 2
0
    private static void SaveToGalleryInternal(string path, string album, MediaType mediaType, MediaSaveCallback callback)
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        string savePath = AJC.CallStatic <string>("SaveMedia", Context, (int)mediaType, path, album);

        File.Delete(path);

        if (callback != null)
        {
            callback(!string.IsNullOrEmpty(savePath), savePath);
        }
#elif !UNITY_EDITOR && UNITY_IOS
        if (mediaType == MediaType.Audio)
        {
            Debug.LogError("Saving audio files is not supported on iOS");

            if (callback != null)
            {
                callback(false, null);
            }

            return;
        }

        Debug.Log("Saving to Pictures: " + Path.GetFileName(path));

        NGMediaSaveCallbackiOS.Initialize(callback);
        if (mediaType == MediaType.Image)
        {
            _NativeGallery_ImageWriteToAlbum(path, album, PermissionFreeMode ? 1 : 0);
        }
        else if (mediaType == MediaType.Video)
        {
            _NativeGallery_VideoWriteToAlbum(path, album, PermissionFreeMode ? 1 : 0);
        }
#else
        if (callback != null)
        {
            callback(true, null);
        }
#endif
    }
Exemplo n.º 3
0
    private static void SaveToGalleryInternal(string path, string album, MediaType mediaType, MediaSaveCallback callback)
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        AJC.CallStatic("SaveMedia", Context, (int)mediaType, path, album);

        File.Delete(path);

        if (callback != null)
        {
            callback(null);
        }
#elif !UNITY_EDITOR && UNITY_IOS
        if (mediaType == MediaType.Audio)
        {
            if (callback != null)
            {
                callback("Saving audio files is not supported on iOS");
            }

            return;
        }

        Debug.Log("Saving to Pictures: " + Path.GetFileName(path));

        NGMediaSaveCallbackiOS.Initialize(callback);
        if (mediaType == MediaType.Image)
        {
            _NativeGallery_ImageWriteToAlbum(path, album);
        }
        else if (mediaType == MediaType.Video)
        {
            _NativeGallery_VideoWriteToAlbum(path, album);
        }
#else
        if (callback != null)
        {
            callback(null);
        }
#endif
    }