I am new to Loadermax, and I recently started working on a new project that has multiple videos that need to be played on different pages, but at the same time keeping the videos in the background buffering so they can be played easily without waiting for them to buffer. For example, I have 3 pages, on page 1, page 2 and page 3, each individual page will have a different video coming from the same XML file. Right now I have all the videos playing in the same swf and they play as a playlist. here is the code. Any guidance on how to get this working would be greatly appreciated. This is also the link to the video player http://outermedia.ca/videoplayer/godaddy/
//an array containing the VideoLoaders in the order they should be played
private var _videos:Array;
//keeps track of the VideoLoader that is currently playing
private var _currentVideo:VideoLoader;
//If true, the audio has been muted
private var _silentMode:Boolean;
//Check if we are in PlayAll Mode (true)
private var smoothing : Boolean = true;
//tracks whether or not the video was paused when the user moused-down on the scrubber. We must pause for scrubbing, but this tells us whether or not to playVideo() when the user releases the mouse.
private var _preScrubPaused:Boolean;
public function Main() {
LoaderMax.activate([xmlLoader, VideoLoader]);
initUI();
var xmlLoader:XMLLoader = new XMLLoader("xml/videoList.xml", {name:"videoList", onComplete:xmlHandler});
xmlLoader.load();
}
private function xmlHandler(event:LoaderEvent):void {
//get the LoaderMax named "videoListLoaded" which was inside our XML
var queue:LoaderMax = LoaderMax.getLoader("videoListLoader");
//store the nested VideoLoaders in an array
_videos = queue.getChildren();
//start loading the queue of VideoLoaders (they will load in sequence)
//ignore mouse interaction with progressBar_mc so that clicks pass through to the loadingBar_mc whose listener handles skipping the video to that spot.
controlUI_mc.progressBar_mc.mouseEnabled = false;
//ignore mouse interaction with preloader_mc
preloader_mc.mouseEnabled = false;
//the "layer" blendMode makes the alpha fades cleaner (overlapping objects don't add alpha levels)
controlUI_mc.blendMode = "layer";
//set the progress and loading bars and the scrubber to the very beginning
//If the video is paused, we should togglePlayPause() so that the new video plays and the interface matches.
if (_currentVideo.videoPaused) {
togglePlayPause();
}
//fade out the preloader and then stop() it. If the new video needs to display the preloader, that's okay because the fade-in tween we create later will overwrite this one.
//prioritizing the video ensures that it moves to the top of the LoaderMax gueue and any other loaders that were loading are canceled to maximize bandwidth available for the new video.
_currentVideo.prioritize(true);
//play() the preloader and fade its alpha up.
preloader_mc.play();
TweenMax.to(preloader_mc, 0.3, {autoAlpha:1});
}
//start playing the video from its beginning
_currentVideo.gotoVideoTime(0, true);
//always start with the volume at 0, and fade it up to 1 if necessary.
_currentVideo.volume = 0;
if (!_silentMode) {
TweenMax.to(_currentVideo, 0.8, {volume:1});
}
//when we addChild() the VideoLoader's content, it makes it rise to the top of the stacking order
//if the VideoLoader hasn't received its metaData yet (which contains duration information), we should set up a listener so that the total time gets updated when the metaData is received.
How to load only one video from an array of XML videos
in Loading (Flash)
Posted
Hello everyone,
I am new to Loadermax, and I recently started working on a new project that has multiple videos that need to be played on different pages, but at the same time keeping the videos in the background buffering so they can be played easily without waiting for them to buffer. For example, I have 3 pages, on page 1, page 2 and page 3, each individual page will have a different video coming from the same XML file. Right now I have all the videos playing in the same swf and they play as a playlist. here is the code. Any guidance on how to get this working would be greatly appreciated. This is also the link to the video player http://outermedia.ca/videoplayer/godaddy/
XML: