Skip to main content
Participant
January 10, 2012
Question

flvpayback preloader percent with VideoEvent.READY

  • January 10, 2012
  • 1 reply
  • 626 views

Hello,

I'm trying to get a dynamic tex box to go from 0 to100%, 100% would be when videoEvent is ready. I cant think of a way to do this. Any suggestions? I guess I need to know how many bytes it takes for VideoEvent.READY to happen.

heres my code as of right now..

import fl.video.*;

import fl.controls.ProgressBarMode;

// Set Variables

var flvControl = display;

var flvSource = "main_vid.flv";

// Create event handler functions to control the progressbar

function progressHandler(event:VideoProgressEvent):void

{

   var bl = Math.round(event.bytesLoaded/1000);

   var bt = Math.round(event.bytesTotal/1000);

   // Update progress...

   pb.setProgress(bl,bt);

  

   loader_txt.text = Math.floor((loaded/total)*100)+ "%";

}

function readyHandler(event:VideoEvent):void

{

   // Remove progressbar when we start playing...

     removeChild(pb);

     removeChild(loader_txt);

}

// Set progress bar state

pb.mode = ProgressBarMode.MANUAL;

pb.indeterminate = false;

// Add listeners and load the video

flvControl.addEventListener(VideoProgressEvent.PROGRESS, progressHandler);

flvControl.addEventListener(VideoEvent.READY, readyHandler);

flvControl.source = flvSource;

Thanks,

Mark

This topic has been closed for replies.

1 reply

Mark_MM00Author
Participant
January 10, 2012

OK, so I think I was misunderstanding Video.Event.READY.. It just states that the video is ready and not downloaded(correct me if I'm wrong).

So I need to use display.playWhenEnoughDownloaded();, but how would I get the bytes out of that method? Any suggestions?

Thanks,

Mark

kglad
Community Expert
Community Expert
January 10, 2012

you should be able to use the event properties shown in your message.  i just don't think you can determine when enough has downloaded to trigger some other event like playWhenEnoughDownloaded() will be dispatched.  but you could test that and see if there's a pattern based on the video bitrate and your connection speed.