Hi,
So I’ve been building a FLV Player in AS3.0 and have come across a little hickup!
Consider this code I created:
//Check Load Progress Function
function checkProgress(e:TimerEvent):void {
//Calculate Ratio
var nRatioLoaded:Number = nsStream.bytesLoaded / nsStream.bytesTotal;
//Calculate Esitmated Time
var nTimeLoaded:Number = Math.round(nDuration * nRatioLoaded);
//Calculate Estimated Percentage over Time
var nTimePercentage:Number = ((nTimeLoaded / nDuration) * 100) / 100;
trace(nTimePercentage);
//Scale PreloadBar
mcPreloader.mcPreloadBar.scaleX = nTimePercentage;
//Smooth Animation
e.updateAfterEvent();
}
Note: nDuration is the Video metaData.duration -
My issue is that the loaded percent over time (which I am using to scale a preloaded bar scaleX is actually not the real percentage over time. I think its something to do with bytes / time / needing to use bitwise (which I am unfamiliar with).
Whilst it does kind of work, sometimes the play head actually moves in front of the preloaded bar as loaded percentage versus time percentage is not being calculated on the same “playing field”.
Can anyone help please?
Cheers,
Ryan