Ejemplo n.º 1
0
        } //END CallSaveToCameraRollEvent

        //-----------------------------//
        public void SavePhotoToCameraRoll()
        //-----------------------------//
        {
#if NATSHARE
            if( blockEventExternalCamera != null )
            {
                //If we're trying to save the photo from the external camera straight to the camera roll 
                //( instead of to the local storage path in the app using the BlockEventRecorder)
                if( cameraAssetToSaveToRoll == SaveExternalCameraTypeToCameraRoll.CapturedPhoto &&
                    blockEventExternalCamera.capturedPhotos != null && blockEventExternalCamera.capturedPhotos.Count > 0 )
                {
                    if( recorderSaveToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.capturedPhotos[ 0 ] ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                    else if( recorderSaveToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.capturedPhotos[ blockEventExternalCamera.capturedPhotos.Count - 1 ] ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs SavePhotoToCameraRoll() ERROR: Missing NATSHARE scripting define symbol in project settings");
            return;
#endif

        } //END SavePhotoToCameraRoll
 public void OnShareButtonClick()
 {
     NatShare.Share(texture,
                    () => {
         Debug.Log("sharing is complete.");
     });
 }
Ejemplo n.º 3
0
    IEnumerator TakeScreen()
    {
        yield return(new WaitForEndOfFrame());

        Texture2D screen = ScreenCapture.CaptureScreenshotAsTexture();

        NatShare.Share(screen);
    }
Ejemplo n.º 4
0
        public void OnButtonShareScreenshotClicked()
        {
            Debug.Log("OnButtonShareScreenshotClicked");

            if (screenshotTexture2D == null)
            {
                print("screenshot is null");
            }

            NatShare.Share(screenshotTexture2D);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Raises the share button click event.
        /// </summary>
        public void OnShareButtonClick()
        {
            Debug.Log("OnShareButtonClick ()");

            if (isVideoPlaying || NatCorder.IsRecording || string.IsNullOrEmpty(videoPath))
            {
                return;
            }

            NatShare.ShareMedia(videoPath, "PATH:" + videoPath);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Raises the save to camera roll button click event.
        /// </summary>
        public void OnSaveToCameraRollButtonClick()
        {
            Debug.Log("OnSaveToCameraRollButtonClick ()");

            if (isVideoPlaying || NatCorder.IsRecording || string.IsNullOrEmpty(videoPath))
            {
                return;
            }

            NatShare.SaveToCameraRoll(videoPath);
        }
Ejemplo n.º 7
0
 void ClickShareButton() // Share screenshot image.
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         new NativeShare().AddFile(screenshotImagePath).Share();
     }
     else
     {
         NatShare.ShareImage(iosShareImage);
     }
 }
Ejemplo n.º 8
0
 private static IntPtr Create (bool color, bool landscape) {
     switch (Application.platform) {
         case RuntimePlatform.Android:
         case RuntimePlatform.IPhonePlayer:
             NatShare.CreatePrintPayload(color, landscape, out var payload);
             return payload;
         default:
             Debug.LogWarning($"NatShare: PrintPayload is not supported on {Application.platform}");
             return IntPtr.Zero;
     }
 }
Ejemplo n.º 9
0
 public void shareSelf()
 {
     Debug.Log("DeEnqueued");
     //SocialShareSheet _shareSheet = new SocialShareSheet();
     //_shareSheet.Text = "We solved the mystery! #riddleMiaThis #mia";
     //_shareSheet.AttachImageAtPath(tempFile);
     //NPBinding.UI.SetPopoverPointAtLastTouchPosition(); // To show popover at last touch point on iOS. On Android, its ignored.
     //NPBinding.Sharing.ShowView(_shareSheet, FinishedSharing);
     //Texture2D myText = imageTexture.texture as Texture2D;
     NatShare.Share(myTexture, "We solved the mystery! #riddleMiaThis #mia");
 }
Ejemplo n.º 10
0
    void OnReplay(string path)
    {
        Debug.Log("Saved recording to: " + path);
        // Playback the video
#if UNITY_IOS
        Handheld.PlayFullScreenMovie("file://" + path);
        NatShare.SaveToCameraRoll(path);
#elif UNITY_ANDROID
        //Handheld.PlayFullScreenMovie(path);
        Debug.Log(path);
        NatShare.SaveToCameraRoll(path);
#endif
    }
Ejemplo n.º 11
0
        private static IntPtr Create(string album)
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
            case RuntimePlatform.IPhonePlayer:
                NatShare.CreateSavePayload(album, out var payload);
                return(payload);

            default:
                Debug.LogWarning($"NatShare: SavePayload is not supported on {Application.platform}");
                return(IntPtr.Zero);
            }
        }
        public void OnButtonSaveScreenshotClicked()
        {
            Debug.Log("OnButtonSaveScreenshotClicked");
            if (!File.Exists(GetPathScreenshot()))
            {
                Debug.LogError("Screenshot not exist\nPath: " + GetPathScreenshot());
                return;
            }

            Debug.Log("Screenshot\nPath: " + GetPathScreenshot());
            byte[] screenshotFile = File.ReadAllBytes(GetPathScreenshot());
            screenshotTexture2D = new Texture2D(Screen.width, Screen.height);
            screenshotTexture2D.LoadImage(screenshotFile);
            NatShare.SaveToCameraRoll(screenshotTexture2D);
        }
Ejemplo n.º 13
0
        } //END CallEvent

        //------------------------------//
        private void CallShareTextureEvent()
        //------------------------------//
        {
#if NATSHARE
            if( textureToShare != null )
            {
                NatShare.ShareImage( textureToShare as Texture2D, messageToShow );

                if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs CallShareTextureEvent() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallShareTextureEvent
Ejemplo n.º 14
0
        } //END CallShareTextureEvent

        //-----------------------------//
        private void CallShareAssetAtPathEvent()
        //-----------------------------//
        {

#if NATSHARE
            if( assetPathToShare != "" )
            {
                NatShare.ShareMedia( assetPathToShare, messageToShow );

                if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs CallShareAssetAtPathEvent() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallShareAssetAtPathEvent
Ejemplo n.º 15
0
        } //END CallShareAssetAtPathEvent

        //-----------------------------//
        private void CallShareBlockEventRecorder()
        //-----------------------------//
        {

#if NATSHARE
            if( blockEventRecorder != null )
            {
                if( assetType == AssetType.Video )
                {
                    if( blockEventRecorder.recordedVideos != null && blockEventRecorder.recordedVideos.Count > 0 )
                    {
                        if( recorderShareType == RecorderShareType.ShareLatest )
                        {
                            NatShare.ShareMedia( blockEventRecorder.recordedVideos[ blockEventRecorder.recordedVideos.Count - 1 ], messageToShow );
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else if( recorderShareType == RecorderShareType.ShareFirst )
                        {
                            NatShare.ShareMedia( blockEventRecorder.recordedVideos[0], messageToShow );
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }
                else if( assetType == AssetType.Texture )
                {
                    if( blockEventRecorder.capturedPhotos != null && blockEventRecorder.capturedPhotos.Count > 0 )
                    {
                        if( recorderShareType == RecorderShareType.ShareLatest )
                        {
                            NatShare.ShareMedia( blockEventRecorder.capturedPhotos[ blockEventRecorder.capturedPhotos.Count - 1 ], messageToShow );
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else if( recorderShareType == RecorderShareType.ShareFirst )
                        {
                            NatShare.ShareMedia( blockEventRecorder.capturedPhotos[ 0 ], messageToShow );
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }

            }
#else
            Debug.LogError("BlockEventNativeSharing.cs CallShareBlockEventRecorder() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallShareBlockEventRecorder
Ejemplo n.º 16
0
 // Invoked by NatCorder once video recording is complete
 private void OnRecording(string path)
 {
     // Share
     if (shareRecordings)
     {
         NatShare.ShareMedia(path);
     }
     // Playback the recording
     else
     {
                     #if UNITY_EDITOR
         UnityEditor.EditorUtility.OpenWithDefaultApp(path);
                     #elif UNITY_IOS
         Handheld.PlayFullScreenMovie("file://" + path);
                     #elif UNITY_ANDROID
         Handheld.PlayFullScreenMovie(path);
                     #endif
     }
 }
Ejemplo n.º 17
0
    IEnumerator CaptureScreenshot()
    {
        yield return(null);

        GameObject.Find("MainCanvas").GetComponent <Canvas>().enabled = false;
        //Wait for end of frame
        yield return(new WaitForEndOfFrame());

        screenImage = new Texture2D(Screen.width, Screen.height);

        //Get Image from screen
        screenImage.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        screenImage.Apply();

        NatShare.SaveToCameraRoll(screenImage);

        GameObject.Find("MainCanvas").GetComponent <Canvas>().enabled = true;

        Texture2D.Destroy(screenImage);
    }
    private IEnumerator Compartir()
    {
        Debug.Log(link);
        UnityWebRequest www = UnityWebRequest.Get(link);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log("Network error: " + www.error);
        }
        while (!www.downloadHandler.isDone)
        {
            yield return(null);
        }
        string result = Path.Combine(Application.temporaryCachePath, $"{num}.mp3");

        File.WriteAllBytes(result, www.downloadHandler.data);
        NatShare.ShareMedia(result);
        Debug.Log("File downloaded in: " + result);
    }
Ejemplo n.º 19
0
    public void ShareScreenshot()
    {
        //AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        //AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");

        //intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        //AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        //AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + snapShot);
        //intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
        //intentObject.Call<AndroidJavaObject>("setType", "image/png");

        //intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), ShareMessage);

        //AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        //AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

        //AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Share Picture");
        //currentActivity.Call("startActivity", jChooser);

        Texture2D image = tex;

        NatShare.Share(image);
    }
Ejemplo n.º 20
0
        void OnReplay(string path)
        {
            if (!Replay.IsRecording)
            {
                duration = Time.time - videoStartTime;
                // Share the video

                if (duration > 3.0f)
                {
                    NatShare.Share(path);
                    Debug.Log("Saved recording to: " + path + " Time Length = " + duration);
                    ScreenBlocker.SetActive(false);
                }
                else
                {
                    Message.text = "Video too short! \r\n Tap and hold longer please.";
                    Debug.Log("Video too short =" + duration);
                }

                //Handheld.PlayFullScreenMovie("file://" + path);
                //NatShare.SaveToCameraRoll(path);
            }
        }
Ejemplo n.º 21
0
        } //END SavePhotoToCameraRoll

        //-----------------------------//
        private void CallRequestVideoThumbnailEvent()
        //-----------------------------//
        {

#if NATSHARE
            Texture2D thumbnail = null;

            if( IsThumbnailAtPath() && assetPathOfVideo != null && assetPathOfVideo != "" )
            {
                thumbnail = NatShare.GetThumbnail( assetPathOfVideo, timeInVideoForThumbnail );
            }
            else if( IsThumbnailAtBlockEventRecorder() && blockEventRecorderWithVideo != null )
            {
                if( blockEventRecorderWithVideo.recordedVideos != null && blockEventRecorderWithVideo.recordedVideos.Count > 0 )
                {
                    if( thumbnailType == RecorderThumbnailType.GetThumbnailFromLatestVideo )
                    {
                        thumbnail = NatShare.GetThumbnail( blockEventRecorderWithVideo.recordedVideos[ blockEventRecorderWithVideo.recordedVideos.Count - 1 ], timeInVideoForThumbnail );
                    }
                    else if( thumbnailType == RecorderThumbnailType.GetThumbnailFromFirstVideo )
                    {
                        thumbnail = NatShare.GetThumbnail( blockEventRecorderWithVideo.recordedVideos[0], timeInVideoForThumbnail );
                    }
                }
                
            }
            
            if( thumbnail != null )
            {
                RequestThumbnailComplete( thumbnail );
            }

#else
            Debug.LogError("BlockEventNativeSharing.cs CallRequestVideoThumbnailEvent() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallRequestVideoThumbnailEvent
 public void OnButtonShareScreenshotClicked()
 {
     NatShare.Share(screenshotTexture2D);
     Debug.Log("OnButtonShareScreenshotClicked");
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Raises the save to camera roll button click event.
        /// </summary>
        public void OnSaveToCameraRollButtonClick()
        {
            Debug.Log("OnSaveToCameraRollButtonClick ()");

            NatShare.SaveToCameraRoll(texture);
        }
Ejemplo n.º 24
0
        } //END CallShareBlockEventRecorder

        //-----------------------------//
        private void CallSaveToCameraRollEvent()
        //-----------------------------//
        {

#if NATSHARE
            if( SaveToCameraRollTypeTexture() && textureToSave != null )
            {
                if( NatShare.SaveToCameraRoll( textureToSave as Texture2D ) )
                {
                    if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                }
            }
            else if( SaveToCameraRollTypePath() && assetPathToSave != null && assetPathToSave != "" )
            {
                if( NatShare.SaveToCameraRoll( assetPathToSave ) )
                {
                    if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                }
            }
            else if( SaveToCameraRollTypeBlockEventExternalCamera() && blockEventExternalCamera != null )
            {
                //Tell the BlockEventExternalCamera that we want to send any photos it captures to the device's camera roll
                if( IsSaveCapturedPhotoToRoll() )
                {
                    blockEventExternalCamera.RequestCapturedPhoto( this );
                }

                //Tell the BlockEventExternalCamera that we want to send the video preview to the device's camera roll
                else if( IsSaveCapturedVideoPreviewToRoll() )
                {
                    if( cameraAssetToSaveToRoll == SaveExternalCameraTypeToCameraRoll.VideoPreview &&
                         blockEventExternalCamera.GetVideoPreview() != null )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.GetVideoPreview() as Texture2D ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }
            }
            else if( SaveToCameraRollTypeBlockEventRecorder() && blockEventRecorderToSaveToRoll != null )
            {
                if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() At start of trying to save to camera roll. AssetType = " + assetTypeToSaveToRoll + ", capturedPhotos.Length = " + blockEventRecorderToSaveToRoll.capturedPhotos.Count + ", capturedVideos.Length = " + blockEventRecorderToSaveToRoll.recordedVideos.Count ); }

                //If we're trying to save an asset from a Recorder to the camera roll
                if( assetTypeToSaveToRoll == AssetType.Texture &&
                    blockEventRecorderToSaveToRoll.capturedPhotos != null && blockEventRecorderToSaveToRoll.capturedPhotos.Count > 0 )
                {
                    if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.capturedPhotos[ 0 ] ) )
                        {
                            if( showDebug ){ Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Succesfully saved Photo! " + blockEventRecorderToSaveToRoll.capturedPhotos[ 0 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                    else if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.capturedPhotos[ blockEventRecorderToSaveToRoll.capturedPhotos.Count - 1 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Success! " + blockEventRecorderToSaveToRoll.capturedPhotos[ blockEventRecorderToSaveToRoll.capturedPhotos.Count - 1 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                }

                //Otherwise if we're trying to save a recorded video to the camera roll
                else if( assetTypeToSaveToRoll == AssetType.Video &&
                    blockEventRecorderToSaveToRoll.recordedVideos != null && blockEventRecorderToSaveToRoll.recordedVideos.Count > 0 )
                {
                    if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.recordedVideos[ 0 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Success! " + blockEventRecorderToSaveToRoll.recordedVideos[ 0 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                    else if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.recordedVideos[ blockEventRecorderToSaveToRoll.recordedVideos.Count - 1 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Success!" + blockEventRecorderToSaveToRoll.recordedVideos[ blockEventRecorderToSaveToRoll.recordedVideos.Count - 1 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs CallSaveToCameraRollEvent() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallSaveToCameraRollEvent
Ejemplo n.º 25
0
 public void OnSaveToCameraRollButtonClick()
 {
     NatShare.SaveToCameraRoll(texture, "NatCamWithOpenCVForUnityExample");
 }
Ejemplo n.º 26
0
 public bool SaveToCameraRoll(string videoPath)
 {
     return(NatShare.SaveToCameraRoll(videoPath));
 }
Ejemplo n.º 27
0
 public void GetThumbnail(string videoPath, Action <Texture2D> callback)
 {
     NatShare.GetThumbnail(videoPath, callback);
 }
Ejemplo n.º 28
0
    public void Share(string videoPath)
    {
#if UNITY_IOS || UNITY_ANDROID
        NatShare.Share(videoPath);
#endif
    }
Ejemplo n.º 29
0
 public void NativeShare()
 {
     vid.Stop();
     cnvPreview.enabled = false;
     NatShare.Share(_path, OnShare);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Raises the share button click event.
        /// </summary>
        public void OnShareButtonClick()
        {
            Debug.Log("OnShareButtonClick ()");

            NatShare.Share(texture);
        }