"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

Cloud Recognition + VidePlayBack + Set Path from JSON

Hello, I have a proyect in unity with Vuforia. I'm using the CloudRecognition and VideoPayback. The problem appears when I try to set the url of the video at the code.

If I set the url (http://clips.vorwaerts-gmbh.de/VfE_html5.mp4) through the inspector of Unity, all works fine. But if I try to change this value at the code, the value changes, but later that the object has builded.

In this post explains a similar problem, but I don't find any solution. https://developer.vuforia.com/forum/cloud-recognition/video-player-problem&sort=2

 

This is the code CloudRecoTrackableEventHandler: 

 private void OnTrackingFound()
    {
		Renderer[] rendererComponents = GetComponentsInChildren<Renderer> (true);
		Collider[] colliderComponents = GetComponentsInChildren<Collider> (true);
		//GetComponentInChildren<Canvas> ().enabled = true;

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

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

		// Stop finder since we have now a result, finder will be restarted again when we lose track of the result
		ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker> ();
		if (objectTracker != null) {
			objectTracker.TargetFinder.Stop ();
		}

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

		//Video

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

		video.m_path = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4";
	
		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;

		//Video end
	}

 

This is the part of code that is executed before that I assign the url

VideoPlaybackBehaviour: 

 

void Start()
    {
        // Find the icon plane (child of this object)
        mIconPlane = transform.Find("Icon").gameObject;



        // A filename or url must be set in the inspector
        if (m_path == null || m_path.Length == 0)
        {
            Debug.Log("Please set a video url in the Inspector");
            HandleStateChange(VideoPlayerHelper.MediaState.ERROR);
            mCurrentState = VideoPlayerHelper.MediaState.ERROR;
            this.enabled = false;
        }
        else
        {
            // Set the current state to Not Ready
            HandleStateChange(VideoPlayerHelper.MediaState.NOT_READY);
            mCurrentState = VideoPlayerHelper.MediaState.NOT_READY;
        }
        // Create the video player and set the filename
        mVideoPlayer = new VideoPlayerHelper();
        mVideoPlayer.SetFilename(m_path);

        // Flip the plane as the video texture is mirrored on the horizontal
        transform.localScale = new Vector3(-1 * Mathf.Abs(transform.localScale.x),
                transform.localScale.y, transform.localScale.z);

        // Scale the icon
        ScaleIcon();
    }

 

I know this is an old post but, the way I could play the url I'm getting from my metadata was using the video.setfilename(metadata); The problem I have with this is that my video is getting played in fullscreen only. Did you find a solution to this?