"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

two different targets both play videos at the same time

Hi there I'm having a problem when i assign this script to two different image targets with a quad attached called Video Plane which has a movie attached. Each of the two image targets have different videos. However as soon as one image target is found both videos play even though you cant see one of them you can hear it playing in the background. I need only the video associated with that target to play and when the image target is lost for it to pause until it is found again. This is the script i'm using any help would be greatly appreciated

 

 

 

/*============================================================================== Copyright (c) 2017 PTC Inc. All Rights Reserved.

Copyright (c) 2010-2014 Qualcomm Connected Experiences, Inc. All Rights Reserved. Confidential and Proprietary - Protected under copyright and other laws. ==============================================================================*/

using UnityEngine; using Vuforia;

// need to import video functionality using UnityEngine.Video; [RequireComponent(typeof(VideoPlayer))]

/// <summary> ///     A custom handler that implements the ITrackableEventHandler interface. /// </summary> public class DefaultTrackableEventHandler : MonoBehaviour, ITrackableEventHandler {     #region PRIVATE_MEMBER_VARIABLES

    protected TrackableBehaviour mTrackableBehaviour;     // setup the videoPlayer object     public VideoPlayer videoPlayer;     public VideoPlayer videoPlayer2;

    #endregion // PRIVATE_MEMBER_VARIABLES

    #region UNTIY_MONOBEHAVIOUR_METHODS

    protected virtual void Start()     {         mTrackableBehaviour = GetComponent<TrackableBehaviour>();         if (mTrackableBehaviour)             mTrackableBehaviour.RegisterTrackableEventHandler(this);

        // add the following 4 lines to get the reference to the video player component of the plane that the video is attached to         // IMPORTANT: set "Video_plane" to the name of the plane game object you attached your video to         GameObject video = GameObject.Find("Video_plane");         videoPlayer = video.GetComponent<VideoPlayer>();         videoPlayer.Play();         videoPlayer.Pause();         // see the VideoPlayer Scripting API for more ideas on which functions you can use in your code         // for example changing the playback speed or jumping to a speicific point in time:         // https://docs.unity3d.com/ScriptReference/Video.VideoPlayer.html      

        // add the following 4 lines to get the reference to the video player component of the plane that the video is attached to         // IMPORTANT: set "Video_plane" to the name of the plane game object you attached your video to         GameObject video2 = GameObject.Find("Donkey");         videoPlayer2 = video2.GetComponent<VideoPlayer>();         videoPlayer2.Play();         videoPlayer2.Pause();     }

    #endregion // UNTIY_MONOBEHAVIOUR_METHODS

    #region PUBLIC_METHODS

    /// <summary>     ///     Implementation of the ITrackableEventHandler function called when the     ///     tracking state changes.     /// </summary>     public void OnTrackableStateChanged(         TrackableBehaviour.Status previousStatus,         TrackableBehaviour.Status newStatus)     {         if (newStatus == TrackableBehaviour.Status.DETECTED ||             newStatus == TrackableBehaviour.Status.TRACKED ||             newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)         {             //Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");             // Play the video:             Debug.Log("Play!");             OnTrackingFound();             videoPlayer.Play();             videoPlayer2.Play();             //videoPlayer.SetDirectAudioVolume(0, 1);             //videoPlayer2.SetDirectAudioVolume(0, 1);         }         else if (previousStatus == TrackableBehaviour.Status.TRACKED &&                  newStatus == TrackableBehaviour.Status.NO_POSE)         {             //Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");             // Pause the video, if using Stop() the video would always play back from the beginning again             Debug.Log("Stop!");             OnTrackingLost();                                    videoPlayer2.Pause();             videoPlayer.Pause();

        }         else         {             // For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND             // Vuforia is starting, but tracking has not been lost or found yet             // Call OnTrackingLost() to hide the augmentations             OnTrackingLost();                     }     }

    #endregion // PUBLIC_METHODS

    #region PRIVATE_METHODS

    protected virtual void OnTrackingFound()     {         var rendererComponents = GetComponentsInChildren<Renderer>(true);         var colliderComponents = GetComponentsInChildren<Collider>(true);         var canvasComponents = GetComponentsInChildren<Canvas>(true);

        // Enable rendering:         foreach (var component in rendererComponents)             component.enabled = true;

        // Enable colliders:         foreach (var component in colliderComponents)             component.enabled = true;

        // Enable canvas':         foreach (var component in canvasComponents)             component.enabled = true;           }

    protected virtual void OnTrackingLost()     {         var rendererComponents = GetComponentsInChildren<Renderer>(true);         var colliderComponents = GetComponentsInChildren<Collider>(true);         var canvasComponents = GetComponentsInChildren<Canvas>(true);

        // Disable rendering:         foreach (var component in rendererComponents)             component.enabled = false;

        // Disable colliders:         foreach (var component in colliderComponents)             component.enabled = false;

        // Disable canvas':         foreach (var component in canvasComponents)             component.enabled = false;               }

    #endregion // PRIVATE_METHODS }