unity3d - How to play video on image target vuforia and unity?


Keywords:unity3d 


Question: 

I want to autoplay video on image target.

I am working with vuforia and unity..

P.S. I tried to do this with vuforia video playback but its not working


2 Answers: 

This is more of a Unity thing, after you apply the video to the object in your scene, you will then need to create a script attached to the object that plays the video:

 

You have to configure it inside DefaultTrackableEventHandler class. Take a video player variable inside the above mentioned class.

public VideoPlayer vidPlay;

Now inside OnTrackableStateChanged configure it like this:

vidPlay = mTrackableBehaviour.GetComponentInChildren<VideoPlayer>();
//This will get current component video

Now Play or Pause your video according to your need. An snippet would be like this:

if (newStatus == TrackableBehaviour.Status.DETECTED ||
     newStatus == TrackableBehaviour.Status.TRACKED ||
     newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
 {
     vidPlay.Play();
     OnTrackingFound();
 }
 else
 {
     vidPlay.Pause();
     OnTrackingLost();
 }

Hope this helps!