Log in or register to post comments

Max Number of Video Playback Objects

August 7, 2012 - 12:18pm #1

I have an example where it would be ideal to have 10 videos arranged in a sort of grid on my target.  Out of the box, only the first four videos load, other videos display the error icon (x).  I notice lines like this in the log, although I'm not sure all of this is relevant:

2012-08-07 12:05:29.129 appName[3634:707] Error - AVAssetReader not in reading state

 

2012-08-07 12:05:29.131 appName[3634:707] Error - Unable to prepare media for playback

 

Could not load video 'myVideoName.m4v' for media type ON_TEXTURE_FULLSCREEN

 
Note that it's not the actual .m4v file that's the problem.  If I make sure that myVideoName.m4v is one of 4 or less video objects, it will load fine.  Any thoughts on how I might approach this?

Max Number of Video Playback Objects

December 26, 2013 - 6:54am #9

To support 30 videos, you'll need to load and unload them programmatically at runtime using the VideoPlayerHelper API, which is accessed using the VideoPlayer property of the video player instance. You also may need to store the videos remotely and stream them to your app via HTTP - if so, load them using their URL. 

Take a look at the VideoPlayback sample's Trackable Event Handler script to see how the VideoPlayerHelper API is employed.

Max Number of Video Playback Objects

December 26, 2013 - 5:27am #8

I have same isseu, i want to play 30 videos in videoplayback.

is it possibe?

Max Number of Video Playback Objects

August 10, 2012 - 11:13am #7

Thanks Malzbier - so, you've been able to load more than 4 video objects at once using this approach?

Max Number of Video Playback Objects

August 10, 2012 - 9:33am #6

The concept works fine thanks :)

This is my funktion to do this (Special fo me but with some nice edititng this will work for you too)

private void OnTrackingFound ()
    {
        Debug.Log("FOUND TRACKER" + this.gameObject.name);
       
       
       
        GameObject videoplayer = GameObject.Find ("Videoplayer");
        videoplayer.transform.parent = this.transform;
        videoplayer.transform.localPosition = new  Vector3 (0, 0.005f, 0);
       
       
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer> ();
       
        videoplayer.active = true;
        // Enable rendering:

       
        VideoPlaybackBehaviour video = GetComponentInChildren<VideoPlaybackBehaviour> ();
       
        VideoPlayerHelper player = video.VideoPlayer;
        video.KeyframeTexture = previewImage;
        player.Unload();
        
          
        // if( player.Unload() ){ // unload the old video
        if (player.Load (path, VideoPlayerHelper.MediaType.ON_TEXTURE_FULLSCREEN, false, 0.0f)) {
            Debug.Log ("success");
        } else {
            Debug.Log ("failure");  
        }
        video.m_path = path;
        video.renderer.material.mainTexture = previewImage;
        videoplayer.GetComponent<AsigenShader>().AsigneShader();
       
       
        Debug.Log(videoplayer.transform.localScale);
        videoplayer.transform.localScale = new Vector3(-0.0625f,0.1f,0.1f);
       
       
        foreach (Renderer component in rendererComponents) {
            component.enabled = true;
        }
       
        Debug.Log ("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }

Max Number of Video Playback Objects

August 8, 2012 - 6:01pm #5

You'd need to instantiate the Video prefab. But what I meant was to assign the videos to the prefab instances dynamically. Here is an example of how to load and unload videos on a prefab instance at runtime.You would attach this to the parent ImageTarget.

 

using UnityEngine;
using System.Collections;

public class VideoSwitcher : MonoBehaviour {
   
    VideoPlaybackBehaviour video;
    VideoPlayerHelper player;
 
   
    void OnGUI(){
       
       
        if( GUILayout.Button("Switch Video") ){
           
            video  = GetComponentInChildren<VideoPlaybackBehaviour>();
            player = video.VideoPlayer;
           
           
            if( player.Unload() ){ // unload the old video
               

                // load the new video
                if( player.Load("newvideo.m4v",VideoPlayerHelper.MediaType.ON_TEXTURE_FULLSCREEN, false, 0.0f ) ){
               
                    Debug.Log("success");
               
                }else{
               
                    Debug.Log("failure");
               
                }
            }else{
                Debug.Log("Failed to Unload Player");   
            }
           
           
        }
    }
}

Max Number of Video Playback Objects

August 8, 2012 - 4:28pm #4

DavidBeard wrote:

Also have your tried loading an playing these at runtime using the VideoPlayerHelper API via the VideoPlaybackBehaviour's VideoPlayer property? 

So far I've been unable to programmatically create VideoPlayer objects using the VideoPlayerHelper API. 

Max Number of Video Playback Objects

August 7, 2012 - 5:02pm #3

I have tried replace the prefab instance, it didn't seem to help.  This isn't too surprising as I can take a project with 5 or 6 video prefabs in it, and as long as I delete any two, all remaining video objects always load correctly (in other words, it doesn't seem that there are certain corrupted ones).

I'll take a look at the second suggestion... I'm still a bit clumsy in Unity / C#, so it may take me a while to figure out how to properly instantiate these video objects using the VideoPlayerHelper API, but it should make good practice for me.

Max Number of Video Playback Objects

August 7, 2012 - 4:47pm #2

Have you tried replacing the Video prefab instance? I've occasionally seen Unity corrupt the prefab instance, resulting in what you're seeing.

Also have your tried loading an playing these at runtime using the VideoPlayerHelper API via the VideoPlaybackBehaviour's VideoPlayer property?

 

Log in or register to post comments