Ignore:
Timestamp:
02/05/09 11:52:44 (4 years ago)
Author:
jeroen
Message:

added a variable for respecting the duration and fixed a stall-on-repeat bug in http

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/as3/com/jeroenwijering/models/HTTPModel.as

    r154 r157  
    4141        /** Load offset for bandwidth checking. **/ 
    4242        protected var loadtimer:Number; 
     43        /** Variable that takes reloading into account (since it takes some time before stream.time is restarted) **/ 
     44        protected var iterator:Number; 
    4345 
    4446 
     
    119121        override public function load(itm:Object):void { 
    120122                super.load(itm); 
    121                 if(stream) { 
     123                position = timeoffset; 
     124                if(stream.bytesLoaded + byteoffset < stream.bytesTotal) { 
    122125                        stream.close(); 
    123126                } 
    124127                model.mediaHandler(video); 
    125128                stream.play(getURL()); 
     129                iterator = 0; 
    126130                clearInterval(interval); 
    127131                interval = setInterval(positionInterval,100); 
     
    196200        /** Interval for the position progress **/ 
    197201        override protected function positionInterval():void { 
    198                 position = Math.round(stream.time*10)/10; 
    199                 if (mp4) {  
    200                         position += timeoffset; 
     202                iterator++; 
     203                if(iterator > 10) { 
     204                        position = Math.round(stream.time*10)/10; 
     205                        if (mp4) { 
     206                                position += timeoffset; 
     207                        } 
    201208                } 
    202209                var bfr:Number = Math.round(stream.bufferLength/stream.bufferTime*100); 
     
    217224                var off:Number = getOffset(pos); 
    218225                if(off < byteoffset || off >= byteoffset+stream.bytesLoaded) { 
    219                         timeoffset = getOffset(pos,true); 
     226                        timeoffset = position = getOffset(pos,true); 
    220227                        byteoffset = off; 
    221228                        load(item); 
     
    244251                                model.sendEvent(ModelEvent.ERROR,{message:'Video not found: '+item['file']}); 
    245252                                break; 
    246                         default: 
    247                                 model.sendEvent(ModelEvent.META,{info:evt.info.code}); 
    248                                 break; 
    249                 } 
     253                } 
     254                model.sendEvent(ModelEvent.META,{info:evt.info.code}); 
    250255        }; 
    251256 
     
    254259        override public function stop():void { 
    255260                super.stop(); 
    256                 if(stream.bytesLoaded < stream.bytesTotal) { 
     261                if(stream.bytesLoaded+byteoffset < stream.bytesTotal) { 
    257262                        stream.close(); 
    258263                } else {  
Note: See TracChangeset for help on using the changeset viewer.