# Incremental percentage buffering

**URL:** <https://forum.kirupa.com/t/incremental-percentage-buffering/214525>\
**Category:** Uncategorized\
**Created:** [January 29, 2007, 8:30pm UTC](https://forum.kirupa.com/t/incremental-percentage-buffering/214525 "2007-01-29T20:30:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![olly76](https://avatars.discourse-cdn.com/v4/letter/o/6a8cbe/32.png) [@olly76](https://forum.kirupa.com/u/olly76)\
**Post date:** [January 29, 2007, 8:30pm UTC](https://forum.kirupa.com/t/incremental-percentage-buffering/214525/1 "2007-01-29T20:30:11Z")

</div>

Hi,

I’m building a site using lots of live action footage similar to this ([http://www.shaveeverywhere.com](http://www.shaveeverywhere.com)), and want a buffering system, whereby say 10% of the FLV loads, then gets the video to play. I’d like a constant check on the percentage loaded, so that there is always an extra 10% of the video loaded to ensure smooth playback. If that percentage loaded drops below the 10% extra mark, the video should pause and a buffering message appear, while the percentage loaded gets above that extra 10% buffer mark.

I can’t use the netStream setBuffer property, as it screws with cue points I have in the video.

This is the start of the code I’ve got at the moment:

if (\_root.getBytesLoaded() \> 0)  
{  
percentDone = Math.floor(\_root.getBytesLoaded() / \_root.getBytesTotal() \* 100);  
loaderVideo.gotoAndStop(percentDone);

```
    trace("percentDone: " + percentDone);
    if (percentDone &gt;= 1)
    {
        if (percentDone &lt; (percentDone + 2)) {
            stop();
            currentLoaded = percentDone;
            buffering._visible = true;
        } else {
            buffering._visible = false;
            play();
        }
                  clearInterval(intervalID);

```

All this code is in an interval. At the moment, every time that statement is checked, it is going to be working from a new percentageLoaded number, so it needs to lock in a number from the instant that percentage falls BELOW the 10% buffer, and keep working from that same percentage until the buffer goes above the 10% mark.  
I used 1% as a test, and added 2% on to that for checking the buffer.

I’m not entirely sure I’ve explained this properly, in fact I’m almost positive I haven’t as I’ve confused myself, but if anyone has any idea what I’m talking about, and can offer a solution, I’d be massively grateful.

Olly.
