Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
calimero

Problem with progress bar and Loadermax

Recommended Posts

Hi,
 
I try to load a video (mp4) with Loadermax but I have a problem with the progressbar. When I test the flash movie in local everything is ok , the progress bar progress until the end and the movie start. But when I put the files on the servor, the progress bar just progress a little bit and disappear before the movie start.
Does someone has an idea of what happen?
Thank you.

Here is my code:

 

import com.greensock.*;
import com.greensock.plugins.*;
import com.greensock.easing.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import com.greensock.loading.display.ContentDisplay;

var loader:SelfLoader = new SelfLoader(this, {name:"self", onProgress:progressHandler, onComplete:completeHandler});
var video:VideoLoader = new VideoLoader("Medias/Videos/trainstationnight4_2.mp4", {name:"myVideo", container:this, width:1920, height:1080, autoPlay:false, volume:0});
var queue:LoaderMax = new LoaderMax({onProgress:progressHandler, onComplete:completeHandler});
queue.append(loader); //just to include the root swf in the progress calculations
queue.append(video);
queue.load();

function progressHandler(event:LoaderEvent):void {
 progressBar_mc.scaleX = event.target.progress;
}

function completeHandler(event:LoaderEvent):void {
video.playVideo();
TweenLite.to(video, 2, {volume:0.5});
}

function errorHandler(event:LoaderEvent):void {
    trace("error occured with " + event.target + ": " + event.text);
}
 

Link to comment
Share on other sites

Hard to tell by just looking at the code. Nothing jumps out at me as being wrong. The fact that it works locally makes me think everything is good on your end. Have you tried loading different videos from that server or maybe the same video from another server?

 

Have you tried clearing your browser cache when you test? Any better?

 

Feel free to post your fla (zipped) and hard-code the url to the video into the VideoLoader

 

new VideoLoader("http://www.yoursite.com/Medias/Videos/trainstationnight4_2.mp4", {...})

 

You mentioned that the progress bar disappears. I don't see any code that would do that.

 

If you can post a testable file, it would really help. Thanks.

Link to comment
Share on other sites

Thanks, don't need your production files, the working code above is all.

I noticed something, your SelfLoader and LoaderMax are using the same onComplete and onProgress handler, which i'm not sure is necessary or good. I doubt you want to call playVideo() before the video is loaded. Anyway,  I removed the SelfLoader from the equation and modified the code slightly:

 

import com.greensock.*;
import com.greensock.plugins.*;
import com.greensock.easing.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import com.greensock.loading.display.ContentDisplay;

var video:VideoLoader = new VideoLoader("trainstationnight4_2.mp4", {name:"myVideo", container:vd, width:1920, height:1080, autoPlay:false, volume:0});
var queue:LoaderMax = new LoaderMax({onProgress:progressHandler, onComplete:completeHandler});
queue.append(video);
queue.load();


function progressHandler(event:LoaderEvent):void {
 progressBar_mc.scaleX = event.target.progress;
 message_txt.text =  event.target.progress;
}




function completeHandler(event:LoaderEvent):void {
video.playVideo();
TweenLite.to(video, 2, {volume:0.5});
TweenLite.to(progressBar_mc, 1,{alpha:0});
}


function errorHandler(event:LoaderEvent):void {
    trace("error occured with " + event.target + ": " + event.text);
}

I'm adding the video to a movie clip called vd so that it doesn't cover the progress bar.

 

You can see it working here:

http://greensock.com/temp/loadvideo/loadvideo.html

 

I've attached an fla

loadvideo.fla.zip

Link to comment
Share on other sites

Thanks a lot! It is working now.

Just one thing more. The bar is progressing and after a while there is a black rectangle who appear before the video. Is it possible to avoid that?

Thank you.

Boris.

Link to comment
Share on other sites

Sure, just like you are tweeinging the volume, in your VideoLoader constructor , set alpha to 0, 

 

new VideoLoader("trainstationnight4_2.mp4", {name:"myVideo", container:vd, alpha:0, width:1920, height:1080, autoPlay:false, volume:0});

 

and then in your onComplete hander, tween the alpha to 1

 

function completeHandler(event:LoaderEvent):void {
video.playVideo();
TweenLite.to(video, 2, {volume:0.5});
TweenLite.to(progressBar_mc, 1,{alpha:0});


// *** NEW
TweenLite.to(video.content, 1, {alpha:1});
}
Link to comment
Share on other sites

Hi,

 

Thanks a lot. It is working well.

I have one more question (last..). If I want to replace the progress bar by a small animation,  what is the best way to do with Loadermax?

Thank you.

Boris.

Link to comment
Share on other sites

It really depends on how you build your small animation.

 

Is it a MovieClip animation? or something scripted using TimelineLite/Max.

 

I'd suggest building a TimelineLite() timeline and then using the progress of the LoaderMax to control the progress() of the TimelineLite()

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.
×