//this attempts to load a video from the preloaded video cache, // stops the last video playing to this texture if nobody else is using it, // and calls a method to resize the texture if necessary. //returns true if it could find the video that has been attempted to load. //returns false if it can't. virtual public bool drawVideoToTexture(int index){ //print(videos[index] + " is ATTEMPTING TO LOAD"); //if the movie you're trying to load does not have a null name and is less than the video count if(index < videos.Count && !System.String.IsNullOrEmpty(videos[index])){ //if the list of videos actually contains that video if(videoManagerScript.preLoadedInstances.ContainsKey(videos[index])){ //get the object we want to load, selected from the name we chose VideoObject myObj = videoManagerScript.preLoadedInstances[videos[index]]; if(myObj.getErrorVideoLoading()){ //Debug.Log(gameObject.name + "VideoTexture:drawVideoToTexture:: ERROR LOADING"); return false; } playingVideoIndex = index; if(myObj == videoObject){ //Debug.Log(gameObject.name + "VideoTexture:drawVideoToTexture:: trying to load an already loaded file"); //trying to load a video that already is playing on this object. //there are a number of ways to handle this- i just chose this for myself. you may change this... myObj.setVideoPosition(0.0f); myObj.setVideoPaused(false); return true; } //cache old video VideoObject cachedObj = videoObject; //test if someone else is using the currently loaded video bool someoneElseIsUsingTheVideo = isAnyoneElseUsingThisVideo(); //assign the new video videoObject = myObj; //initialize using the volume, speed, isPaused, and loopType settings from the last video played. videoObject.initFrom(cachedObj); resizeTexturesFromVideoResolution(); //clean up the old video if(!someoneElseIsUsingTheVideo){ cachedObj.setVideoPosition(0.0f); cachedObj.setVideoPaused(true); } }//contains the video requested else{ return false; } } //array index > the videos in the queue or video requested is null string else{ print("VideoInstance::drawVideoToTexture: tried to pass a null string as video name!"); return false; } return true; }
public void createVideoObject(){ VideoObject cachedObj = videoObject; //create a new movie object reference with the path videoObject = new VideoObject(fullPathToMovie); //set it to use the full path, instead of one relative to your video manager's pre-set path videoObject.setUseAbsolutePath(true); //store the settings that you setup in the inspector. videoObject.initFrom(cachedObj); }