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
}