简体   繁体   中英

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

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?

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM