Estimating time to download a file (FLV / MP3)


i trying estimate how take user download mp3 /flv file.

 

 

private function init():void {                _netstream = new netstream(_netconnection);                                _netstream.play(test.flv");                 _netstream.client = _metadataobj;                 bandwidth = new timer(3000,1);                 bandwidth .addeventlistener(timerevent.timer , oncalculatebandwidth, false , 0 , true);                 bandwidth .start();                  checkvideoprogress = new timer(100,0);                 checkvideoprogress.addeventlistener(timerevent.timer , onvideoprogresshandler , false , 0 , true);                 checkvideoprogress.start();                 _starttime=gettimer(); }   private function onvideoprogresshandler(e:timerevent):void  {                               if (_netstream.bytesloaded == _netstream.bytestotal)                 {                     trace("actual download time = " + math.ceil((gettimer() - _starttime)/1000));                                  checkvideoprogress.stop();                                    }   }   private function oncalculatebandwidth(e:timerevent):void  {      var timetodownloadfile:number= math.ceil((3 * _netstream.bytestotal) / _netstream.bytesloaded); } 

 

so check bytesloaded in 3 seconds  , try estimate how long take download bytestotal reason numbers way off

 

24 sec when actual download time 10 sec

330 sec when actual download time 26sec

 


thanks,

firdosh



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts