Ejemplo n.º 1
0
    public void StopRec()
    {
                #if UNITY_EDITOR
        Debug.Log("Cannot make recordings in editor");
        return;
                #endif

        if (!isInitialized)
        {
            return;
        }

        Debug.Log("Stop Rec try");

        if (isRecording)
        {
                        #if UNITY_ANDROID
            //Images2Video Style:
            androidRecordingCamera.EndShot(HandleSessionCompleteDelegate);
                        #endif

                        #if UNITY_IOS
            //VidCapPro Style:
            vidCapManager.EndRecordingSession(iVidCapPro.VideoDisposition.Save_Video_To_Album, out recFrames);
            //session complete delegate registered via VidCapPro
                        #endif

            Camera.main.GetComponent <Blitter>().enabled = false;
            Camera.main.targetTexture = null;

            isRecording = false;
        }
    }
Ejemplo n.º 2
0
    public void StopRec()
    {
        if (!isInitialized)
        {
            return;
        }

//		Debug.Log("Stop Rec try");

        if (isRecording)
        {
//			Debug.Log("Stop Rec -- Start Stop");
                        #if UNITY_ANDROID && !UNITY_EDITOR
            MergeAndroidBridge.StopRecording();
                        #endif
//			Debug.Log("Stop Rec -- Native Done");
                        #if UNITY_IOS && !UNITY_EDITOR
            vidCapManager.EndRecordingSession(iVidCapPro.VideoDisposition.Save_Video_To_Album, out recFrames);
                        #endif

            if (MergeCubeSDK.instance.viewMode == MergeCube.MergeCubeBase.ViewMode.FULLSCREEN)
            {
                Camera.main.targetTexture = null;
                fullscreenRecordingCamera.SetActive(false);
            }
            else
            {
                                #if UNITY_IOS
                Camera.main.targetTexture = MergeCubeSDK.instance.GetHeadsetTexture();
                                #endif
            }
//			Debug.Log("Stop Rec -- ViewSetDone");
                        #if UNITY_IOS
            MergeCubeSDK.instance.videoTexture.SetTexture("_Texture", MergeCubeSDK.instance.GetHeadsetTexture());
                        #endif
            recordingTexture = null;

            MergeCubeScreenRotateManager.instance.UnlockCurrentOrientation();
            Resources.UnloadUnusedAssets();
//			Debug.Log("Stop Rec -- Set Texture Done");

            if (!MergeCubeSDK.deviceIsTablet)
            {
                MergeCubeSDK.instance.AddMenuElement(MergeCubeSDK.instance.viewSwitchButton, 3);

                if (MergeCubeSDK.instance.viewMode == MergeCubeBase.ViewMode.HEADSET)
                {
                    MergeCubeSDK.instance.AddMenuElement(MergeCubeSDK.instance.headsetCompatabilityButton, 4);
                }
            }

//			Debug.Log("Stop Rec -- Done Set Recording False");

            isRecording = false;

                        #if UNITY_ANDROID && !UNITY_EDITOR
            HandleRecSaveComplete();
                        #endif
        }
    }
    // This function is called when the "Stop" button is pressed.
    public void StopVideoRecording()
    {
        if (!isRecording)
        {
            return;
        }

        isRecording = false;
        videoAction = iVidCapPro.VideoDisposition.Save_Video_To_Album;
        //videoAction = iVidCapPro.VideoDisposition.Save_Video_To_Documents;

        iVidCapPro.SessionStatusCode rc;
        int framesRecorded = 0;

        // Stop the video recording and end the session.
        // Assuming the recording didn't abort, we get the number of frames recorded
        // returned as the result.

        // Have we requested mixing additional audio files?
        if (audioSourceState > AudioSource.Scene)
        {
            string audioFilePath1 = null;
            string audioFilePath2 = null;
            // Get the device path to the audio files from StreamingAssets/Audio.
            string assetsDir = Path.Combine(Application.streamingAssetsPath, "Audio");
            //string assetsDir = Application.dataPath + "/Raw/Audio";
            if (audioSourceState == AudioSource.User_File_1 || audioSourceState == AudioSource.User_File_1_2 ||
                audioSourceState == AudioSource.All)
            {
                string audioFileName1 = "Seagulls.mp3";
                audioFilePath1 = Path.Combine(assetsDir, audioFileName1);
                if (showDebug)
                {
                    Debug.Log("iVidCapPro - audio file 1 to mix:" + audioFilePath1);
                }
            }
            if (audioSourceState == AudioSource.User_File_2 || audioSourceState == AudioSource.User_File_1_2 ||
                audioSourceState == AudioSource.All)
            {
                string audioFileName2 = "Arpeggiator.mp3";
                audioFilePath2 = Path.Combine(assetsDir, audioFileName2);
                if (showDebug)
                {
                    Debug.Log("iVidCapPro - audio file 2 to mix:" + audioFilePath2);
                }
            }

            // Use this call if you want to mix the video with your own audio file.
            // Make sure the files you pass in exist!
            rc = vrController.EndRecordingSessionWithAudioFiles(videoAction, audioFilePath1, audioFilePath2, out framesRecorded);
        }
        else
        {
            // We're not mixing in an additional audio file.
            // Either no audio or audio captured only from the scene.
            rc = vrController.EndRecordingSession(videoAction, out framesRecorded);
        }

        // Disable video capture and reactivate main audio listener.
        if (mainCamera != null && (videoSourceState == VideoSource.Main_Camera ||
                                   videoSourceState == VideoSource.Both_Cameras))
        {
            // We were recording from the main camera and main listener.
            vrCap         = (iVidCapProVideo)mainCamera.GetComponent <iVidCapProVideo>();
            vrCap.enabled = false;
        }
        if (secondaryCamera != null && (videoSourceState == VideoSource.Secondary_Camera ||
                                        videoSourceState == VideoSource.Both_Cameras))
        {
            vrCap         = (iVidCapProVideo)secondaryCamera.GetComponent <iVidCapProVideo>();
            vrCap.enabled = false;

            // Turn off secondary camera.
            secondaryCamera.enabled = false;

            // If we were recording solely from the secondary camera we were using the
            // secondary listener.  Make sure the main listener is turned on the secondary
            // listener is off.
            if (mainListener != null)
            {
                mainListener.enabled = true;
            }
            if (secondaryListener != null)
            {
                secondaryListener.enabled = false;
            }
        }

        // Disable audio capture.
        if (arCap != null)
        {
            arCap.enabled = false;
        }

        // Check to see if the video recording was successful.
        // If so, we display a message asking the user to wait while the video
        // is finalized.  This is not necessary since our app is still usable
        // during the final video processing and how this is handled in the actual
        // app would vary depending on the circumstances.  The requirement that must
        // be honored is that a new recording session may not be started until the
        // previous session is fully complete.
        if (rc == iVidCapPro.SessionStatusCode.OK)
        {
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                ShowMessage("Please wait...", 9999.0f);
            }
            else
            {
                // Our session complete delegate will never be invoked in the editor.
                // So just wait a few seconds for the look of the thing.
                ShowMessage("Please wait...", 5.0f);
            }
        }
    }
Ejemplo n.º 4
0
    void EndRecording()
    {
        int framesRecorded;

        vr.EndRecordingSession(iVidCapPro.VideoDisposition.Save_Video_To_Album, out framesRecorded);
    }