Jump to content
GreenSock

friendlygiraffe

Switching videos

Recommended Posts

I'm finding it difficult to switch switch a VideoLoader to a different Video

 

Aside from adding the VideoLoader inside an MC and then removing it that way, but I'd prefer a cleaner approach:

 

var myNum = 0;
loadNewVid(null);
addChild(video.content);
video.addEventListener(VideoLoader.VIDEO_COMPLETE, loadNewVid);
private function loadNewVid(event:Event)
 {
  myNum ++;
  Main.VidList.push(Main.VidList[0]);
  Main.VidList.shift();

  video = LoaderMax.getLoader(Main.myXML.cars.car[myNum].VideoLoader.@url);
  video.content.height = Main.vidHeight;
  origScale = video.content.scaleY;
  video.content.scaleX = origScale;
  video.content.centerRegistration = true;
  video.bufferMode = true;
}

Link to comment
Share on other sites

you could re-use the same VideoLoader and just change its url property and reload it.

 

myVideoLoader.url = Main.myXML.cars.car[myNum].VideoLoader.@url
myVideoLoader.load(true);//load new video and flush existing content

 

A benefit here is that you don't have to re-define callbacks or other settings each time AND the previously watched video always gets flushed.

 

there are at least 3 ways of handling a mult-video setup

 

1)load all the videos at once (which i think is what you are doing from your last post). The downside here is that you can use up a lot of available memory

 

2)create a new VideoLoader each time a new video is created (on demand).

 

3)re-use the same VideoLoader over and over and change the url as shown above.

 

Each way has its pro's and cons. If you are going to use multiple VideoLoaders (1 for each video) yes, you will have to devise a plan to swap the content of those videos in and out of the display and also make sure your controls (if you have them), play, pause, and volume know which video to control.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×