Hi
I want to play differnt videos on detection of different image targets. We are able to play a video on single image target but are not able to play when there are multiple image targets and multiple videos. We have placed tap script on the image target.
plzz help
- Sort Posts
- 12 replies
- Last post
multiple videos with multiple image targets
Re: multiple videos with multiple image targets
Hi kim..
i am able to run multiple videos on different images but now i want that this video should come from net. Is it possible to have any method which could directly connect me to the videos on our local server? Right now we are putting our videos in streaming assets of our unity application.
We are using this function but the video is not getting opened when we use this
iPhoneUtils.PlayMovie("http://172.17.199.76:8080/VideoSupport/intro.mp4", Color.yellow, iPhoneMovieControlMode.Full);
Re: multiple videos with multiple image targets
Re: multiple videos with multiple image targets
Look at Script/TrackableEventHandler.cs in the sample applications. It uses GetComponent
- Kim
Re: multiple videos with multiple image targets
How do we obtain reference to the calling TrackableBehaviour from the context of an ImageTarget's TrackableEventHandler? I want to be able to handle state changes independently for each target.
i.e. how are you obtaining mTrackableBehaviour in your example?
I can retrieve the TrackableBehaviours by calling Object.FindObjectsByType(), but I haven't found a way to reference a target's TrackableBehaviour directly. Calling FindObjectByType() always returns the same object regardless of context.
For instance, I can register the handlers as follows, but this method is redundant, and each handler's start() registers the event handler for each TrackableBehaviour - and then there's still no way to determine which target the status change arises from.
public class TrackableEventHandler : MonoBehaviour , ITrackableEventHandler { TrackableBehaviour[] trackables; // Initialize & Register Event Handler void Start () { trackables = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType( typeof(TrackableBehaviour)); foreach( TrackableBehaviour trkable in trackables ){ trkable.RegisterTrackableEventHandler(this); Debug.Log("Registering "+trkable.TrackableName); } } // Update is called once per frame void Update () { } // Called when the trackable state has changed. public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus,TrackableBehaviour.Status newStatus){ ... } }
Re: multiple videos with multiple image targets
I believe it will be simplest to call your javascript functions from the C# TrackableEventHandler script. The callbacks there are called at a particular point each frame, it will be harder to poll things from the javascript correctly.
Place your javascript file in the Plugins folder, and drag an instance of it onto the ARCamera object. Then, in TrackableEventHandler.cs you can call javascript functions like this:
private void OnTrackingFound() { ... MyJavascript js = (MyJavascript) FindObjectOfType(typeof(MyJavascript)); js.foundTrackable(mTrackableBehaviour.TrackableName); } private void OnTrackingLost() { ... MyJavascript js = (MyJavascript) FindObjectOfType(typeof(MyJavascript)); js.lostTrackable(mTrackableBehaviour.TrackableName); }
For a MyJavascript.js file that looks like this:
function foundTrackable(trackableName) { print("found trackable " + trackableName); } function lostTrackable(trackableName) { print("lost trackable " + trackableName); }
- Kim
Re: multiple videos with multiple image targets
You can call javascript functions from C#, the only trick is making sure your javascript files are compiled before your C# scripts. One way is to drop the javascript files in the Plugins folder. See the Unity docs:
http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html
- Kim
Re: multiple videos with multiple image targets
Re: multiple videos with multiple image targets
Can you just check the TrackableName and switch the video based on that? Open any of the samples and look at Scripts/TrackableEventHandler.cs. You have access to the trackable name in the OnTrackingFound method:
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
- Kim
Hi,khushboo!
Can you explain please how do you play video on detection of image targets, please?