Log in or register to post comments

Video Playback URL and loading different videos

October 15, 2012 - 1:57am #20

Hi,

I have following questions for Video Playback in Unity

1) I want to play different video for different image target in single dataset. How will I detect which video to play?

2) I want to stream video from server. What is the best approach for that?

3) Should I add video prefab as a child of Imagetarget prefab? Is there anything else to do to make Video Playback functional?

4) How can I load dataset dynamically which might contain different image targets with different videos for each target? Plz tell me the best approach with your experience.

Thanks

Ayaz Alavi

 

Video Playback URL and loading different videos

October 15, 2012 - 2:55am #19

Hi ayazalavi

1 - study the Unity Videoplayback sample as it does exactly this - two targets and two different videos   https://ar.qualcomm.at/qdevnet/

2 - on iOS this will only play full screen if streamed.  The other option is to download to the device and then play

3 - see the Videoplayback sample and follow the structure

4 - you will probably have to use CloudReco when it launches as it solves the problem whereby you cannot change the dataset at runtime

HTH

N

 

N

Video Playback URL and loading different videos

October 15, 2012 - 4:04am #18

NalinS wrote:

1 - study the Unity Videoplayback sample as it does exactly this - two targets and two different videos   https://ar.qualcomm.at/qdevnet/

2 - on iOS this will only play full screen if streamed.  The other option is to download to the device and then play

3 - see the Videoplayback sample and follow the structure

4 - you will probably have to use CloudReco when it launches as it solves the problem whereby you cannot change the dataset at runtime

 

I downloaded unity video plauback package but it doesnt contain demo Unity project. I just imported extension into my Unity project. How can I see sample implementation in Unity project?

Video Playback URL and loading different videos

October 15, 2012 - 5:14am #17

Ok I seethe scene file in the package. Now I am facing issue that if I load my own dataset then unity is not recognizing that and my markers have 3 star ratings in TMS. Here are my trackable sample file https://www.dropbox.com/s/lv2alz5nxnr7um9/sample.unitypackage

 

Can anybody tell what I might be doing wrong? I just change dataset of Imagetarget to my one and it refuses to load any videos after that.

Video Playback URL and loading different videos

October 15, 2012 - 6:00am #16

Also I see this in error log

Trackable NAME lost

Video Playback URL and loading different videos

October 15, 2012 - 6:28am #15

Hi ayazalavi,

There are two steps to make this work:

1 - Click on the AR Camera and in the Inspector (under Data Set Load Behaviour) load and activate the new dataset

2 - Click on the Image Target and in the Inspector (under Image Target Behaviour) select the dataset and the image target within it

Chances are you may have missed one of these...

HTH

N

Video Playback URL and loading different videos

October 15, 2012 - 9:58pm #14

Perfect new dataset is loaded. Now one of my questions is that how can I play multiple videos on one Video prefab. I want to swap videos in random order to play different each time.

Video Playback URL and loading different videos

October 15, 2012 - 11:30pm #13

I have tried using following code in OnTrackingFound method

if(state == VideoPlayerHelper.MediaState.READY || state == VideoPlayerHelper.MediaState.REACHED_END) {
                    Debug.Log("Video Count: " + videos1.Count);
                    // Play this video on texture where it left off
                    if(mTrackableBehaviour.TrackableName.Equals("TRACK1") || mTrackableBehaviour.TrackableName.Equals("TRACK3")) {
                        int randVideo = Random.Range(0, videos1.Count);
                        video.VideoPlayer.Load((string)videos1[randVideo], VideoPlayerHelper.MediaType.ON_TEXTURE, false, 0);
                        Debug.Log("Video selected: " + videos1[randVideo]);
                    }                   
                    if(mTrackableBehaviour.TrackableName.Equals("TRACK2") || mTrackableBehaviour.TrackableName.Equals("TRACK4")) {
                        int randVideo = Random.Range(0, videos2.Count);
                        video.VideoPlayer.Load((string)videos2[randVideo], VideoPlayerHelper.MediaType.ON_TEXTURE, false, 0);
                        Debug.Log("Video selected: " + videos2[randVideo]);
                    }
                }

But above code is not working.

Video Playback URL and loading different videos

October 16, 2012 - 1:17am #12

I finally did it by adding following code before loading code

video.VideoPlayer.Unload();

Video Playback URL and loading different videos

October 16, 2012 - 3:17am #11

My final working code have 1 problem that trackable is getting lost very fast. Below is the code in TrackableEventHandler OnTrackingFound method. Does anybody have any clue that what is wrong.

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

        // Optionally play the video automatically when the target is found
       
        VideoPlaybackBehaviour video = GetComponentInChildren<VideoPlaybackBehaviour>();
        if (video != null)
        {
            if (video.VideoPlayer.IsPlayableOnTexture())
            {
                VideoPlayerHelper.MediaState state = video.VideoPlayer.GetStatus();
                if(state == VideoPlayerHelper.MediaState.REACHED_END) {
                    Debug.Log("Video Count: " + videos1.Count);
                    // Play this video on texture where it left off
                    video.VideoPlayer.Unload();
               
                    if(mTrackableBehaviour.TrackableName.Equals("TRACK1") || mTrackableBehaviour.TrackableName.Equals("TRACK3")) {
                        int randVideo = Random.Range(0, videos1.Count);
                        video.m_path = (string)videos1[randVideo];   
                       
                        //video.VideoPlayer.SetFilename((string)obamaVideos[randVideo]);
                        if( video.VideoPlayer.Load((string)videos1[randVideo], VideoPlayerHelper.MediaType.ON_TEXTURE, true, 0.0f ) ){             
                            Debug.Log("success");                      
                        }else{                      
                            Debug.Log("failure");                      
                        }
                        Debug.Log("Video selected: " + videos1[randVideo]);
                    }                   
                    if(mTrackableBehaviour.TrackableName.Equals("TRACK2") || mTrackableBehaviour.TrackableName.Equals("TRACK4")) {
                        int randVideo = Random.Range(0, videos2.Count);
                        video.m_path = (string)videos2[randVideo];   
                        if( video.VideoPlayer.Load((string)videos2[randVideo], VideoPlayerHelper.MediaType.ON_TEXTURE, true, 0.0f ) ){             
                            Debug.Log("success");                      
                        }else{                      
                            Debug.Log("failure");                      
                        }
                        Debug.Log("Video selected: " + videos2[randVideo]);
                    }
                }
                if (state == VideoPlayerHelper.MediaState.PAUSED ||
                    state == VideoPlayerHelper.MediaState.READY ||
                    state == VideoPlayerHelper.MediaState.STOPPED)
                {
                    // Pause other videos before playing this one
                    PauseOtherVideos(video);
                    Debug.Log("Resume Play");               
                    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
                    Debug.Log("Start Play");
                    video.VideoPlayer.Play(false, 0);
                }   
                else {
                    Debug.Log("NOT PLAYED");
                }
            }
        }

Video Playback URL and loading different videos

October 16, 2012 - 8:34am #10

How do you mean that it's getting lost fast? Is the video not rendering on the target? Is the target not being detected?

 

Video Playback URL and loading different videos

October 16, 2012 - 8:44am #9

it was due to low rated trackable. I just created better trackable and it is solved. Also I checked state with PLAYING for loading new video.

 

Video Playback URL and loading different videos

November 11, 2012 - 6:21am #8

hi,

i m using unity pro 3.5.0, isnt cant run this unity package? i means videoPlayback.unityPackage.

it comes with the error:

Assets/Scripts/TrackableEventHandler.cs(23,38): error CS0246: The type or namespace name `ITrackableEventHandler' could not be found. Are you missing a using directive or an assembly reference?

 

 

thanks

chew

Video Playback URL and loading different videos

November 11, 2012 - 12:31pm #7

Be sure that you've imported the Unity extension into your project. This is available on the same page as the Video Playback sample.

Video Playback URL and loading different videos

November 11, 2012 - 8:49pm #6

thanks! it work!

Video Playback URL and loading different videos

November 11, 2012 - 8:49pm #5

thanks! it work!

hi, im trying to stream a

January 9, 2013 - 2:04am #4

hi,

im trying to stream a video to unity using cloud recognition and video playback. I loaded the demo video from within the project to the imagetarget, but if i press the play button it does nothing!

Is there anything different in the cloud recognition, i mean the imagetarget itself works super, and the video works in my device dataset loading projects!

also if i want to load/stream a video and add it to the video texture, how would i do this?

i tried using the www and the movietexture but the class is not found.

thanx in advance!

Hi jonasdeherdt, So step one

January 9, 2013 - 2:56am #3

Hi jonasdeherdt,

So step one would be to modify the CloudReco sample to incorporate video playback (local, not streamed).  This would need you to combine the code somehow between the two samples.

Does this work?

There is nothing different per se regarding CloudRecognition so it should work.

Regarding streaming from a URL on video playback - it does work in the sample, but will only play back full screen.  The alternative is to download the video to the local store (Documents folder on iOS, SDCard on Android) - then it can play on a texture.

Hope this makes sense.  BTW probably worth searching the forums as this has been discussed before...

N

Video Playback URL and loading different videos

November 20, 2013 - 6:43pm #2

Hey There,

I am also trying to combine Cloud Reco and Video Playback.

I have achieved integration for streaming video when i set the path in the inspector, but when i set it from the metadata, i get a EXC_BAD_ACCESS from the videoLoad part of the following snippet:

 

if (video != null)
{
	Debug.Log( "Video: " + video.m_path );
	 //load Video on tracking, use local variable to skip to position left off at pause
	if( video.VideoPlayer.Load( video.m_path, VideoPlayerHelper.MediaType.ON_TEXTURE, false, mVideoCurrentPosition[ i ] ) )
	{
	}
	Debug.Log( "Video Loaded" );
}

I'm using the exact same path in both instances and am a bit stumped as to what is going on.

Any help greatly appreciated.

Cheers.

Video Playback URL and loading different videos

November 21, 2013 - 3:23am #1

There has to be a difference in the two approaches to explain what is going on.

My only suggestion is to debug it on the actual device either through Unity directly or with XCode/Android debugger.

This way you can more quickly get to the heart of the problem.

 

N

Log in or register to post comments