Jump to content
GreenSock

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

VideoLoader buffer progress freezes on 0% after seek

Recommended Posts

Hello and thank you so much for the most useful AS3 Library I've ever used!

 

I'm currently using a VideoLoader to playback external MP4 on a client website. I've set bufferMode=true and all goes well on short videos. However, on larger videos (about 100MB) when I try to seek the video immediately after the first bufferFull event:

- bufferEmpty is displached properly

- I display a 0% buffer progress info and wait for buffer progress

- It stays at 0% for about 20 seconds! -> My problem

- It then starts to show progress and quickly gets to 100%

- bufferFull is dispached, all is good.

 

I can't quite explain to my client why does this happen on our website and it doesn't happen on youtube. On youtube it starts re-buffering immediately after seeking to a further frame :(

 

I'll post the essential parts of my code and I hope you can give me some insight on this subject, thank you very much in advance.

 

Here is how initialize the loader:

 

// Estimated Bytes are provided on each video
  video = new VideoLoader(url, {container:this, x:bkg.x, y:bkg.y, width:bkg.width, height:bkg.height, scaleMode:"proportionalInside", bgColor:0x000000, autoPlay:false, volume:1, auditSize:false, estimatedBytes:this.estimatedBytes, bufferMode:true, onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
  video.load();
  video.gotoVideoTime(0);

  video.addEventListener(VideoLoader.PLAY_PROGRESS, updatePlayProgress);
  video.addEventListener(VideoLoader.VIDEO_COMPLETE, videoComplete);
  video.addEventListener(VideoLoader.VIDEO_BUFFER_EMPTY, bufferEmptyHandler);
  video.addEventListener(VideoLoader.VIDEO_BUFFER_FULL, bufferFullHandler);
  video.content.addEventListener(MouseEvent.DOUBLE_CLICK, toogleFullScreenMode);

 

Here are the listener functions:

 

public function progressHandler(event:LoaderEvent):void
 {
  trace("progressHandler",(Math.round(event.target.progress*100))+"%");
  // custom code to display progress text
 }

 public function completeHandler(event:LoaderEvent):void
 {
  // custom code to hide buffer progress text
 }

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

 public function bufferEmptyHandler(evt:LoaderEvent):void
 {
  // custom code to show buffer progress text, starting with "0%"
  addEventListener(Event.ENTER_FRAME, reportBufferProgress);
 }

 public function bufferFullHandler(evt:LoaderEvent):void
 {
  trace("bufferFullHandler");
  removeEventListener(Event.ENTER_FRAME, reportBufferProgress);
  completeHandler(null);
 }

 public function reportBufferProgress(evt:Event):void
 {
// ISSUE: it stays at 0% for about 20 seconds on large movies and then evolves super fast to 100%
trace("buffer progress:",video.bufferProgress);
 }

 public function updatePlayProgress(evt:LoaderEvent=null)
 {
  // custom code to show play progress bar
 }

 public function videoComplete(evt:LoaderEvent=null)
 {
  // custom code for when the video is done playing
 }

Link to post
Share on other sites

It sounds like there might be some confusion about progressive downloads vs. streaming downloads (like YouTube). The reason YouTube is so quick to jump to a later spot in the video (before it even loads) is because it uses a completely different technology that requires a special server setup and server-side software (which can be pricey). Streaming technology essentially allows it to jump to any spot and just shoot a request to the server like "hey, just start me at 5:12 into the video and forget loading all the stuff before that..."

 

Like most loaders in Flash, LoaderMax is for progressive downloads. That means the file must be downloaded from start-to-finish (in order). So if you have a 60-minute video and only 30 seconds have downloaded when you try to jump to 50-minutes into the video, it must wait until all 50 minutes has downloaded before it can play that spot.

 

The only ways around that are to shift to a streaming solution (not LoaderMax) or split your video apart into smaller chunks and build your own programming logic to juggle their loading (not exactly simple and it can be tough to achieve perfectly seamless playback between the chunks).

  • Like 2
Link to post
Share on other sites

It sounds like there might be some confusion about progressive downloads vs. streaming downloads (like YouTube). The reason YouTube is so quick to jump to a later spot in the video (before it even loads) is because it uses a completely different technology that requires a special server setup and server-side software (which can be pricey). Streaming technology essentially allows it to jump to any spot and just shoot a request to the server like "hey, just start me at 5:12 into the video and forget loading all the stuff before that..."

 

It was a mistake on my part to assume we were streaming, I assumed that buffering was somewhat related to streaming, but now I recall that in college we setup a streaming server and It was a specific technology altogether. Thank you very much for this enlightening answer :)

Link to post
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.

×