How do I know how much of a video is loaded by a NetStream in AS3?

Go To StackoverFlow.com

1

I'm making a video player in AS3 and was wondering how to find out how much of the video is currently cached/buffered. I'm not sure what the correct terminology is, so I haven't been able to find it in the documentation.

NetStream.time gives me the current location of the video, so based on that I can display a progressbar.

Underneath the progressbar, I want to display how much of the video has been loaded already. How do I find this value?

2012-04-05 01:41
by joon


3

You can use NetSteam.bytesLoaded and NetSteam.bytesTotal to get the total rough percentage loaded:

var bufferPercent:Number = myNetStream.bytesLoaded / myNetStream.bytesTotal;

// Use percentage to scale buffer bar.
myBufferBar.scaleX = bufferPercent;
2012-04-05 01:46
by Marty
Thanks! as a followup question, do you have any idea how I can clear my local cache/buffer? It seems that between development builds, flash has some sort of cache so it is difficult to test the buffer-related code.. - joon 2012-04-05 02:55
@joon Hmm, not sure. But you can use the bandwidth profiler and live simulation when compiling to see how it works which may help - Marty 2012-04-05 04:25
Ads