Example #1
0
    /// <summary>
    /// Overriding base class implementation for double tap handling
    /// </summary>
    protected override void OnDoubleTap()
    {
        base.OnDoubleTap();

        // Get currently playing video, if any,
        // and pause it before the UI menu is opened.
        // This is needed in Unity 5 in order to show the UI menu
        VideoPlaybackBehaviour video = GetPlayingVideo();

        if (video != null && video.VideoPlayer.IsPlayableOnTexture())
        {
            video.VideoPlayer.Pause();
        }
    }
Example #2
0
    /// <summary>
    /// Handle single tap event
    /// </summary>
    private void HandleTap()
    {
        // Find out which video was tapped, if any
        VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);

        details = "entering handleTap";
        if (video != null)
        {
            if (video.VideoPlayer.IsPlayableOnTexture())
            {
                details = "enter playable";
                // This video is playable on a texture, toggle playing/paused

                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video on texture where it left off
                    video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
                }
                else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video from the beginning
                    video.VideoPlayer.Play(false, 0);
                }
                else if (state == VideoPlayerHelper.MediaState.PLAYING)
                {
                    // Video is already playing, pause it
                    //video.VideoPlayer.Pause();
                }
            }
            else
            {
                // Display the busy icon
                video.ShowBusyIcon();

                // This video cannot be played on a texture, play it full screen
                video.VideoPlayer.Play(true, 0);
                mWentToFullScreen = false;
            }
        }
    }
Example #3
0
    /// <summary>
    /// Handle single tap event
    /// </summary>
    private void HandleTap()
    {
        if (mActiveViewType == AppManager.ViewType.ARCAMERAVIEW)
        {
            // Find out which video was tapped, if any
            VideoPlaybackBehaviour video = PickVideo(Input.mousePosition);

            if (video != null)
            {
                if (video.VideoPlayer.IsPlayableOnTexture())
                {
                    // This video is playable on a texture, toggle playing/paused

                    VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                    if (state == VideoPlayerHelper.MediaState.PAUSED ||
                        state == VideoPlayerHelper.MediaState.READY ||
                        state == VideoPlayerHelper.MediaState.STOPPED)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(video);

                        // Play this video on texture where it left off
                        video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
                    }
                    else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(video);

                        // Play this video from the beginning
                        video.VideoPlayer.Play(false, 0);
                    }
                    else if (state == VideoPlayerHelper.MediaState.PLAYING)
                    {
                        // Video is already playing, pause it
                        video.VideoPlayer.Pause();
                    }
                }
                else
                {
                    // Display the busy icon
                    video.ShowBusyIcon();

                    // This video cannot be played on a texture, play it full screen
                    video.VideoPlayer.Play(true, 0);
                }
            }
        }
    }
Example #4
0
    public static IEnumerator PlayFullscreenVideoAtEndOfFrame(VideoPlaybackBehaviour video)
    {
        Screen.orientation                    = ScreenOrientation.AutoRotation;
        Screen.autorotateToPortrait           = true;
        Screen.autorotateToPortraitUpsideDown = true;
        Screen.autorotateToLandscapeLeft      = true;
        Screen.autorotateToLandscapeRight     = true;

        yield return(new WaitForEndOfFrame());

        // we wait a bit to allow the ScreenOrientation.AutoRotation to become effective
        yield return(new WaitForSeconds(0.3f));

        video.VideoPlayer.Play(true, 0);
    }
    private VideoPlaybackBehaviour PickVideo()
    {
        VideoPlaybackBehaviour[] behaviours = GameObject.FindObjectsOfType(typeof(VideoPlaybackBehaviour)) as VideoPlaybackBehaviour[];
        VideoPlaybackBehaviour   video      = null;

        foreach (VideoPlaybackBehaviour bhvr in behaviours)
        {
            if (bhvr.CurrentState == VideoPlayerHelper.MediaState.PLAYING)
            {
                video = bhvr;
            }
        }

        return(video);
    }
Example #6
0
    public static IEnumerator PlayFullscreenVideoAtEndOfFrame(VideoPlaybackBehaviour video)
    {
        Screen.orientation = ScreenOrientation.AutoRotation;
        Screen.autorotateToPortrait = true;
        Screen.autorotateToPortraitUpsideDown = true;
        Screen.autorotateToLandscapeLeft = true;
        Screen.autorotateToLandscapeRight = true;

        yield return new WaitForEndOfFrame ();

        // we wait a bit to allow the ScreenOrientation.AutoRotation to become effective
        yield return new WaitForSeconds (0.3f);

        video.VideoPlayer.Play(true, 0);
    }
Example #7
0
    void OnTrackingLost()
    {
        //GameController.CurrentImageTarget = 0;
        if (fullScreenBtn != null)
        {
            fullScreenBtn.SetActive(false);
        }
        if (StopBtn != null)
        {
            StopBtn.SetActive(false);
        }
        Debug.Log("Track value in VideoBehavior" + DetachTarget.track);

        if (DetachTarget.track)
        {
            Renderer[] rendererComponents = GetComponentsInChildren <Renderer>();
            Collider[] colliderComponents = GetComponentsInChildren <Collider>();

            // Disable rendering:
            foreach (Renderer component in rendererComponents)
            {
                component.enabled = false;
            }

            // Disable colliders:
            foreach (Collider component in colliderComponents)
            {
                component.enabled = false;
            }

            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");


            VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour>();
            if (video != null && video.VideoPlayer != null)
            {
                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PLAYING ||
                    state == VideoPlayerHelper.MediaState.PAUSED)
                {
                    video.VideoPlayer.Stop();
                }
            }

            mLostTracking     = true;
            mSecondsSinceLost = 0;
        }
    }
    // Pause all videos except this one
    private void PauseOtherVideos(VideoPlaybackBehaviour currentVideo)
    {
        VideoPlaybackBehaviour[] videos = (VideoPlaybackBehaviour[])
                                          FindObjectsOfType(typeof(VideoPlaybackBehaviour));

        foreach (VideoPlaybackBehaviour video in videos)
        {
            if (video != currentVideo)
            {
                if (video.CurrentState == VideoPlayerHelper.MediaState.PLAYING)
                {
                    video.VideoPlayer.Pause();
                }
            }
        }
    }
Example #9
0
//		public string videoName = "";

        override protected void OnTrackingFound()
        {
            base.OnTrackingFound();
//			VideoPlaybackBehaviour[] currentVideos = FindObjectsOfType<VideoPlaybackBehaviour>();
//			foreach (VideoPlaybackBehaviour video in currentVideos) {
//				if(video.m_path.Contains (videoName))
//					video.VideoPlayer.Play (false, 0);
//			}
//			Transform transform = GetComponent<Transform>();
//			foreach (Transform child in transform) {
//
//			}
            VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour> ();

            video.VideoPlayer.Play(false, 0);
        }
Example #10
0
    private void PlayVideoFullscreen()
    {
        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren <Collider>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour>();

        Debug.Log("video.AutoPlay " + video.AutoPlay);
        if (video != null && video.AutoPlay)
        {
            //if (video.VideoPlayer.IsPlayableFullscreen())
            {
                //On Android, we use Unity's built in player, so Unity application pauses before going to fullscreen.
                //So we have to handle the orientation from within Unity.
                                #if UNITY_ANDROID
                Screen.orientation = ScreenOrientation.LandscapeLeft;
                                #endif
                // Pause the video if it is currently playing
                video.VideoPlayer.Pause();

                // Seek the video to the beginning();
                video.VideoPlayer.SeekTo(0.0f);

                // Display the busy icon
                video.ShowBusyIcon();

                // Play the video full screen
                StartCoroutine(PlayFullscreenVideoAtEndOfFrame(video));
            }
        }
    }
Example #11
0
    public void PlayFullScreen()
    {
        for (int i = 0; i < Targets.Length; i++)
        {
            if (CurrentImageTarget == i + 1)
            {
                VideoPlaybackBehaviour video = Targets [i].GetComponentInChildren <VideoPlaybackBehaviour>();
                if (video != null && video.VideoPlayer != null)
                {
//						VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
//						if (state == VideoPlayerHelper.MediaState.PAUSED ||
//							state == VideoPlayerHelper.MediaState.READY ||
//							state == VideoPlayerHelper.MediaState.STOPPED)
//						{
//							// Pause other videos before playing this one
//							PauseOtherVideos(video);
//							video.VideoPlayer.Pause();
//							// Play this video on texture where it left off
//							video.VideoPlayer.Play(true, video.VideoPlayer.GetCurrentPosition());
//						}
//						else if (state == VideoPlayerHelper.MediaState.REACHED_END)
//						{
//							// Pause other videos before playing this one
//							PauseOtherVideos(video);
//							video.VideoPlayer.Pause();
//							// Play this video from the beginning
//							video.VideoPlayer.Play(true, 0);
//						}

                    // Pause the video if it is currently playing
                    video.VideoPlayer.Pause();

                    // Seek the video to the beginning();
                    video.VideoPlayer.SeekTo(0.0f);

                    // Display the busy icon
                    video.ShowBusyIcon();
                    StartCoroutine(PlayFullscreenVideoAtEndOfFrame(video));
                    // Play the video full screen
                }
            }
        }
    }
Example #12
0
    private void HandleDoubleTap()
    {
        VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);

        if (video != null)
        {
            if (video.VideoPlayer.IsPlayableFullscreen())
            {
                video.VideoPlayer.Pause();

                video.VideoPlayer.SeekTo(0.0f);

                video.ShowBusyIcon();

                video.VideoPlayer.Play(true, 0);
                mWentToFullScreen = true;
            }
        }
    }
    void Update()
    {
        // Pause the video if tracking is lost for more than two seconds
        if (mHasBeenFound && mLostTracking)
        {
            if (mSecondsSinceLost > 2.0f)
            {
                VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour>();
                if (video != null &&
                    video.CurrentState == VideoPlayerHelper.MediaState.PLAYING)
                {
                    video.VideoPlayer.Pause();
                }

                mLostTracking = false;
            }

            mSecondsSinceLost += Time.deltaTime;
        }
    }
Example #14
0
    public override void OnInspectorGUI()
    {
        // Get the video playback behaviour that is being edited
        VideoPlaybackBehaviour vpb = (VideoPlaybackBehaviour)target;

        // Draw the default inspector
        DrawDefaultInspector();

        // Add an inspector field for the keyframe texture
        vpb.KeyframeTexture = (Texture)EditorGUILayout.ObjectField(
            "Keyframe Texture", vpb.KeyframeTexture, typeof(Texture), false);

        // If the keyframe texture field changed, update the material
        if (GUI.changed)
        {
            UpdateMaterial(vpb);

            EditorUtility.SetDirty(vpb);
        }
    }
    public static void UpdateMaterial(VideoPlaybackBehaviour vpb)
    {
        // Load the reference material
        Material referenceMaterial =
                (Material)AssetDatabase.LoadAssetAtPath(REFERENCE_MATERIAL_PATH,
                                                    typeof(Material));

        if (referenceMaterial == null)
        {
            Debug.LogError("Could not find reference material at " +
                           REFERENCE_MATERIAL_PATH +
                           " please reimport Unity package.");
            return;
        }

        if (vpb.KeyframeTexture == null)
        {
            // Reset to reference material if keyframe texture is null
            vpb.GetComponent<Renderer>().sharedMaterial = referenceMaterial;
        }
        else
        {
            // Create a new material that is based on the reference material and
            // uses the selected keyframe texture
            Material material = new Material(referenceMaterial);

            material.mainTexture = vpb.KeyframeTexture;
            material.name = vpb.KeyframeTexture.name + "Material";
            material.mainTextureScale = new Vector2(-1, -1);
            material.renderQueue = referenceMaterial.renderQueue + 1;

            vpb.GetComponent<Renderer>().sharedMaterial = material;
        }

        // Cleanup assets that have been created temporarily
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
        EditorUtility.UnloadUnusedAssetsImmediate();
#else
        EditorUtility.UnloadUnusedAssets();
#endif
    }
    public static void UpdateMaterial(VideoPlaybackBehaviour vpb)
    {
        // Load the reference material
        Material referenceMaterial =
            (Material)AssetDatabase.LoadAssetAtPath(REFERENCE_MATERIAL_PATH,
                                                    typeof(Material));

        if (referenceMaterial == null)
        {
            Debug.LogError("Could not find reference material at " +
                           REFERENCE_MATERIAL_PATH +
                           " please reimport Unity package.");
            return;
        }

        if (vpb.KeyframeTexture == null)
        {
            // Reset to reference material if keyframe texture is null
            vpb.GetComponent <Renderer>().sharedMaterial = referenceMaterial;
        }
        else
        {
            // Create a new material that is based on the reference material and
            // uses the selected keyframe texture
            Material material = new Material(referenceMaterial);

            material.mainTexture      = vpb.KeyframeTexture;
            material.name             = vpb.KeyframeTexture.name + "Material";
            material.mainTextureScale = new Vector2(-1, -1);
            material.renderQueue      = referenceMaterial.renderQueue + 1;

            vpb.GetComponent <Renderer>().sharedMaterial = material;
        }

        // Cleanup assets that have been created temporarily
#if UNITY_5_0 || UNITY_5_1
        EditorUtility.UnloadUnusedAssetsImmediate();
#else
        EditorUtility.UnloadUnusedAssets();
#endif
    }
Example #17
0
    private void HandleTap()
    {
        VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);

        if (video != null)
        {
            if (video.VideoPlayer.IsPlayableOnTexture())
            {
                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    PauseOtherVideos(video);

                    video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
                }
                else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                {
                    PauseOtherVideos(video);

                    video.VideoPlayer.Play(false, 0);
                }
                else if (state == VideoPlayerHelper.MediaState.PLAYING)
                {
                    video.VideoPlayer.Pause();
                }
            }
            else
            {
                video.ShowBusyIcon();

                video.VideoPlayer.Play(true, 0);
                mWentToFullScreen = true;
            }
        }
    }
    // Handle double tap event
    private void HandleDoubleTap()
    {
        // Find out which video was tapped, if any
        VideoPlaybackBehaviour video = PickVideo(mTouchStartPos);

        if (video != null)
        {
            if (video.VideoPlayer.IsPlayableFullscreen())
            {
                // Pause the video if it is currently playing
                video.VideoPlayer.Pause();

                // Seek the video to the beginning();
                video.VideoPlayer.SeekTo(0.0f);

                // Display the busy icon
                video.ShowBusyIcon();

                // Play the video full screen
                video.VideoPlayer.Play(true, 0);
                mWentToFullScreen = true;
            }
        }
    }
Example #19
0
    /// <summary>
    /// Handle single tap event
    /// </summary>
    private void HandleSingleTap()
    {
        if (QCARRuntimeUtilities.IsPlayMode())
        {
            if (PickVideo(Input.mousePosition) != null)
                Debug.LogWarning("Playing videos is currently not supported in Play Mode.");
        }

        // Find out which video was tapped, if any
        currentVideo = PickVideo(Input.mousePosition);

        if (currentVideo != null)
        {
            if (IsFullScreenModeEnabled())
            {
                if (currentVideo.VideoPlayer.IsPlayableFullscreen())
                {
                    //On Android, we use Unity's built in player, so Unity application pauses before going to fullscreen.
                    //So we have to handle the orientation from within Unity.
        #if UNITY_ANDROID
                    Screen.orientation = ScreenOrientation.LandscapeLeft;
        #endif
                    // Pause the video if it is currently playing
                    currentVideo.VideoPlayer.Pause();

                    // Seek the video to the beginning();
                    currentVideo.VideoPlayer.SeekTo(0.0f);

                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // Play the video full screen
                    StartCoroutine( PlayFullscreenVideoAtEndOfFrame(currentVideo) );

                    UpdateFlashSettingsInUIView();
                }
            }
            else
            {
                if (currentVideo.VideoPlayer.IsPlayableOnTexture())
                {
                    // This video is playable on a texture, toggle playing/paused

                    VideoPlayerHelper.MediaState state = currentVideo.VideoPlayer.GetStatus();
                    if (state == VideoPlayerHelper.MediaState.PAUSED ||
                        state == VideoPlayerHelper.MediaState.READY ||
                        state == VideoPlayerHelper.MediaState.STOPPED)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video on texture where it left off
                        currentVideo.VideoPlayer.Play(false, currentVideo.VideoPlayer.GetCurrentPosition());
                    }
                    else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video from the beginning
                        currentVideo.VideoPlayer.Play(false, 0);
                    }
                    else if (state == VideoPlayerHelper.MediaState.PLAYING)
                    {
                        // Video is already playing, pause it
                        currentVideo.VideoPlayer.Pause();
                    }
                }
                else
                {
                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // This video cannot be played on a texture, play it full screen
                    StartCoroutine( PlayFullscreenVideoAtEndOfFrame(currentVideo) );
                }
            }
        }
    }
Example #20
0
    /// <summary>
    /// Pause all videos except this one
    /// </summary>
    private void PauseOtherVideos(VideoPlaybackBehaviour currentVideo)
    {
        VideoPlaybackBehaviour[] videos = (VideoPlaybackBehaviour[])
                FindObjectsOfType(typeof(VideoPlaybackBehaviour));

        foreach (VideoPlaybackBehaviour video in videos)
        {
            if (video != currentVideo)
            {
                if (video.CurrentState == VideoPlayerHelper.MediaState.PLAYING)
                {
                    video.VideoPlayer.Pause();
                }
            }
        }
    }
Example #21
0
    private void OnTrackingFound()
    {
        LineEffect.SetActive(false);

        PauseOtherVideos(null);


        if (ThisVid != null)
        {
            ThisVid.VideoPlayer.Play(false, RelatedVideoScreen.GetComponent <VideoPlaybackBehaviour>().VideoPlayer.GetCurrentPosition());
        }

        ARCamera.GetComponent <VideoPlaybackController> ().enabled     = true;
        SecondCamera.GetComponent <VideoPlaybackController> ().enabled = false;

        if (RelatedVideoScreen.GetComponent <VideoPlaybackBehaviour> ().VideoPlayer.GetStatus() == VideoPlayerHelper.MediaState.PLAYING)
        {
            RelatedVideoScreen.GetComponent <VideoPlaybackBehaviour> ().VideoPlayer.Pause();
        }

        ThisVid = GetComponentInChildren <VideoPlaybackBehaviour> ();

        RelatedVideoScreen.GetComponent <SetUpSecondScreen> ().Normalized = true;

        RelatedVideoScreen.GetComponent <Renderer> ().enabled = false;
        RelatedVideoScreen.GetComponent <Collider> ().enabled = false;



        Renderer[] rendererComponentsReleted = RelatedVideoScreen.GetComponentsInChildren <Renderer>();
        Collider[] colliderComponentsReleted = RelatedVideoScreen.GetComponentsInChildren <Collider>();

        // Enable rendering:
        foreach (Renderer component in rendererComponentsReleted)
        {
            component.enabled = false;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponentsReleted)
        {
            component.enabled = false;
        }



        ButtonFunction[] UIArray = (ButtonFunction[])FindObjectsOfType <ButtonFunction> ();

        /*for (int pass = 0; pass < UIArray.Length; pass++) {
         *      UIArray [pass].gameObject.GetComponent<Renderer> ().enabled = false;
         *      UIArray [pass].gameObject.GetComponent<Collider> ().enabled = false;
         * }*/

        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren <Collider>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }


        // Optionally play the video automatically when the target is found


        if (ThisVid != null && ThisVid.AutoPlay)
        {
            if (ThisVid.VideoPlayer.IsPlayableOnTexture())
            {
                VideoPlayerHelper.MediaState state = ThisVid.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(ThisVid);

                    // Play this video on texture where it left off

                    ThisVid.VideoPlayer.Play(false, RelatedVideoScreen.GetComponent <VideoPlaybackBehaviour>().VideoPlayer.GetCurrentPosition());
                }
                else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(ThisVid);

                    // Play this video from the beginning
                    ThisVid.VideoPlayer.Play(false, 0);
                }
            }
        }

        mHasBeenFound = true;
        mLostTracking = false;
    }
Example #22
0
        private void OnTrackingFound()
        {
            if (CloudRecoEventHandler.metadata.type == "video")
            {
                // videoObject.SetActive(true);
                threeDObject.SetActive(false);
                Renderer[] rendererComponents = videoObject.GetComponentsInChildren <Renderer>();
                Collider[] colliderComponents = videoObject.GetComponentsInChildren <Collider>();


                // Enable rendering:
                foreach (Renderer component in rendererComponents)
                {
                    component.enabled = true;
                }

                // Enable colliders:
                foreach (Collider component in colliderComponents)
                {
                    component.enabled = true;
                }

                AudioSource[] audioComponents = GetComponentsInChildren <AudioSource>();

                //Play audio:
                foreach (AudioSource component in audioComponents)
                {
                    component.Play();
                }

                Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

                // Optionally play the video automatically when the target is found
                // video.InitializeVideoPlayback ();
                if (video != null)
                {
                    video = GetComponentInChildren <VideoPlaybackBehaviour>();

                    video.m_path = CloudRecoEventHandler.metadata.materialurl;

                    video.VideoPlayer.SetFilename(CloudRecoEventHandler.metadata.materialurl);

                    if (video.VideoPlayer.Load(video.m_path, VideoPlayerHelper.MediaType.ON_TEXTURE, false, mVideoCurrentPosition))
                    {
                        Debug.Log("Loaded video from position : " + mVideoCurrentPosition);
                    }

                    ResumeVideo();
                }
            }
            else if (CloudRecoEventHandler.metadata.type == "3d")
            {
                PauseAndUnloadVideo();
                threeDObject.SetActive(true);
                objReaderCSharpV4 objReader = GetComponentInChildren <objReaderCSharpV4>();
                objReader.StartCoroutine("Init", "GameObject");
            }

            mHasBeenFound = true;
            mLostTracking = false;
        }
 // Use this for initialization
 void Start()
 {
     this.iniciarExplosion();
     video = GetComponentInChildren<VideoPlaybackBehaviour>();
     reproducirSonido=GetComponent<ReproducirSonido>();
 }
Example #24
0
    void OnTrackingFound()
    {
        /* for (int i = 0; i < Camera.main.GetComponent<GameController> ().Targets.Length; i++) {
         *      Camera.main.GetComponent<GameController> ().Targets [i].GetComponent<VideoTrackableEventHandler> ().IsFixed = false;
         *      Renderer[] rendererComponentstarget = Camera.main.GetComponent<GameController> ().Targets[i].GetComponentsInChildren<Renderer>();
         *      Collider[] colliderComponentstarget = Camera.main.GetComponent<GameController> ().Targets[i].GetComponentsInChildren<Collider>();
         *      // Disable rendering:
         *      foreach (Renderer component in rendererComponentstarget)
         *      {
         *              component.enabled = false;
         *      }
         *
         *      // Disable colliders:
         *      foreach (Collider component in colliderComponentstarget)
         *      {
         *              component.enabled = false;
         *      }
         * }
         * GameController.CurrentImageTarget = int.Parse(gameObject.name.Substring(gameObject.name.Length-1));
         */
        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren <Collider>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }
        StopBtn.SetActive(true);
        fullScreenBtn.SetActive(true);
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

        // Optionally play the video automatically when the target is found

        VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour>();

        if (video != null && video.AutoPlay)
        {
            if (video.VideoPlayer.IsPlayableOnTexture())
            {
                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video on texture where it left off
                    video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
                }
                else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video from the beginning
                    video.VideoPlayer.Play(false, 0);
                }
            }
        }

        mHasBeenFound = true;
        mLostTracking = false;
    }
Example #25
0
    /// <summary>
    /// Try to pick video at tap screen position
    /// </summary>
    public void TryPickingVideo()
    {
        if (VuforiaRuntimeUtilities.IsPlayMode())
        {
            if (PickVideo(Input.mousePosition) != null)
            {
                Debug.LogWarning("Playing videos is currently not supported in Play Mode.");
            }
        }

        // Find out which video was tapped, if any
        currentVideo = PickVideo(Input.mousePosition);

        if (currentVideo != null)
        {
            if (playFullscreen)
            {
                if (currentVideo.VideoPlayer.IsPlayableFullscreen())
                {
                    // Pause the video if it is currently playing
                    currentVideo.VideoPlayer.Pause();

                    // Seek the video to the beginning();
                    currentVideo.VideoPlayer.SeekTo(0.0f);

                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // Play the video full screen
                    StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo));
                }
            }
            else
            {
                if (currentVideo.VideoPlayer.IsPlayableOnTexture())
                {
                    // This video is playable on a texture, toggle playing/paused
                    VideoPlayerHelper.MediaState state = currentVideo.VideoPlayer.GetStatus();
                    if (state == VideoPlayerHelper.MediaState.PAUSED ||
                        state == VideoPlayerHelper.MediaState.READY ||
                        state == VideoPlayerHelper.MediaState.STOPPED)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video on texture where it left off
                        currentVideo.VideoPlayer.Play(false, currentVideo.VideoPlayer.GetCurrentPosition());
                    }
                    else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video from the beginning
                        currentVideo.VideoPlayer.Play(false, 0);
                    }
                    else if (state == VideoPlayerHelper.MediaState.PLAYING)
                    {
                        // Video is already playing, pause it
                        currentVideo.VideoPlayer.Pause();
                    }
                }
                else
                {
                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // This video cannot be played on a texture, play it full screen
                    StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo));
                }
            }
        }
    }
Example #26
0
    private void OnTrackingFound()
    {
        // screen caputre value
        capture    = GameObject.FindObjectOfType <screenShotSharing> ().noAnimation;
        newCapture = GameObject.FindObjectOfType <screenShotSharing> ().noPhoneEmailButtons;
        GameObject.FindObjectOfType <screenShotSharing> ().currentPhone = phoneButton;
        GameObject.FindObjectOfType <screenShotSharing> ().currentEmail = emailButton;

        print("this is the noPhoneEmailButtons" + newCapture);

        // if there is phone button get the animator components and rest the animation
        if (phoneButton != null)
        {
            ph    = phoneButton;
            phone = phoneButton.gameObject.GetComponent <Animator> ();
            phone.Play("phoneAnimation", -1, 0f);
        }
        // if there is email button get the animator components and rest the animation
        if (emailButton != null)
        {
            em    = emailButton;
            email = emailButton.gameObject.GetComponent <Animator> ();
            email.Play("emailAnimation", -1, 0f);
        }

        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren <Collider>();
        Canvas []  canvasComponents   = GetComponentsInChildren <Canvas>(true);

        // Enable Canvas
        foreach (Canvas component in canvasComponents)
        {
            component.enabled = true;
        }

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

        // Optionally play the video automatically when the target is found
        VideoPlaybackBehaviour video = GetComponentInChildren <VideoPlaybackBehaviour>();

        if (video != null && video.AutoPlay)
        {
            if (video.VideoPlayer.IsPlayableOnTexture())
            {
                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video on texture where it left off
                    video.VideoPlayer.Play(false, video.VideoPlayer.GetCurrentPosition());
                }
                else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);

                    // Play this video from the beginning
                    video.VideoPlayer.Play(false, 0);
                }
            }
        }

        // if the screen is not been capture
        if (capture == false)
        {
            // active the button and play animation
            if (phoneButton != null)
            {
                phone.gameObject.SetActive(true);
                phone.Play("phoneAnimation");
            }
            if (emailButton != null)
            {
                email.gameObject.SetActive(true);
                email.Play("emailAnimation");
            }
            // if the screen is been captured diactive button
        }
        else if (capture == true)
        {
            if (phoneButton != null)
            {
                phone.gameObject.SetActive(false);
            }
            if (emailButton != null)
            {
                email.gameObject.SetActive(false);
            }
        }

        mHasBeenFound = true;
        mLostTracking = false;
    }
Example #27
0
    /// <summary>
    /// Handle single tap event
    /// </summary>
    private void HandleSingleTap()
    {
        if (QCARRuntimeUtilities.IsPlayMode())
        {
            if (PickVideo(Input.mousePosition) != null)
            {
                Debug.LogWarning("Playing videos is currently not supported in Play Mode.");
            }
        }

        // Find out which video was tapped, if any
        currentVideo = PickVideo(Input.mousePosition);

        if (currentVideo != null)
        {
            if (IsFullScreenModeEnabled())
            {
                if (currentVideo.VideoPlayer.IsPlayableFullscreen())
                {
                    //On Android, we use Unity's built in player, so Unity application pauses before going to fullscreen.
                    //So we have to handle the orientation from within Unity.
#if UNITY_ANDROID
                    Screen.orientation = ScreenOrientation.LandscapeLeft;
#endif
                    // Pause the video if it is currently playing
                    currentVideo.VideoPlayer.Pause();

                    // Seek the video to the beginning();
                    currentVideo.VideoPlayer.SeekTo(0.0f);

                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // Play the video full screen
                    StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo));

                    UpdateFlashSettingsInUIView();
                }
            }
            else
            {
                if (currentVideo.VideoPlayer.IsPlayableOnTexture())
                {
                    // This video is playable on a texture, toggle playing/paused

                    VideoPlayerHelper.MediaState state = currentVideo.VideoPlayer.GetStatus();
                    if (state == VideoPlayerHelper.MediaState.PAUSED ||
                        state == VideoPlayerHelper.MediaState.READY ||
                        state == VideoPlayerHelper.MediaState.STOPPED)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video on texture where it left off
                        currentVideo.VideoPlayer.Play(false, currentVideo.VideoPlayer.GetCurrentPosition());
                    }
                    else if (state == VideoPlayerHelper.MediaState.REACHED_END)
                    {
                        // Pause other videos before playing this one
                        PauseOtherVideos(currentVideo);

                        // Play this video from the beginning
                        currentVideo.VideoPlayer.Play(false, 0);
                    }
                    else if (state == VideoPlayerHelper.MediaState.PLAYING)
                    {
                        // Video is already playing, pause it
                        currentVideo.VideoPlayer.Pause();
                    }
                }
                else
                {
                    // Display the busy icon
                    currentVideo.ShowBusyIcon();

                    // This video cannot be played on a texture, play it full screen
                    StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo));
                }
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     this.iniciarExplosion();
     video            = GetComponentInChildren <VideoPlaybackBehaviour>();
     reproducirSonido = GetComponent <ReproducirSonido>();
 }