Log in or register to post comments

multiple videos with multiple image targets

May 4, 2011 - 5:25am #1

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

Re: multiple videos with multiple image targets

June 18, 2012 - 4:16am #13

Hi,khushboo!
Can you explain please how do you play video on detection of image targets, please?

Re: multiple videos with multiple image targets

May 10, 2011 - 6:11am #12

I believe you need to use iPhoneUtils.PlayMovieURL instead of iPhoneUtils.PlayMovie for streaming from the network.

- Kim

Re: multiple videos with multiple image targets

May 10, 2011 - 3:18am #11

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

May 9, 2011 - 11:57am #10

Where are these sample apps?

I didn't see any mention of them in the docs, or when installing the extension.

* I've posted the same to my inquiry on ITrackables, so we can fold this inquiry into that one.

Re: multiple videos with multiple image targets

May 9, 2011 - 5:57am #9

Look at Script/TrackableEventHandler.cs in the sample applications. It uses GetComponent() to get the TrackableBehaviour attached to a particular trackable object. You can create different trackable event handlers per trackable object, or you can check the TrackableName to do some code switching.

- Kim

Re: multiple videos with multiple image targets

May 7, 2011 - 12:11pm #8

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

May 5, 2011 - 1:45am #7

thnkx kim..its working nw :)

Re: multiple videos with multiple image targets

May 4, 2011 - 7:06pm #6

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

May 4, 2011 - 6:30am #5

Kim actually i want to access the boolean variables declared in TrackableScript.cs into my .js script... hw can i do that??

Re: multiple videos with multiple image targets

May 4, 2011 - 6:15am #4

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

May 4, 2011 - 6:00am #3

yaa we have done that TrackableName switching thing but we want to access this TrackableName in another .js file where we are actually writing the code to play the video.
how can we do that..??

Re: multiple videos with multiple image targets

May 4, 2011 - 5:41am #2

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

Log in or register to post comments