Ignore:
Timestamp:
10/20/08 08:16:10 (5 years ago)
Author:
jeroen
Message:

merged 4.2 player to trunk

File:
1 edited

Legend:

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

    r59 r88  
    11/** 
    2 * Wrapper for playback of progressively downloaded video. 
     2* Wrapper for playback of http 'streaming' video. 
    33**/ 
    44package com.jeroenwijering.models { 
     
    1616import flash.utils.clearInterval; 
    1717import flash.utils.setInterval; 
    18 import flash.utils.Timer; 
    1918 
    2019 
     
    4645        /** Byteposition to which the file has been loaded. **/ 
    4746        private var loaded:Number; 
    48         /** Timer for checking bandwidth **/ 
    49         private var timer:Timer 
    5047 
    5148 
     
    103100        /** Load content. **/ 
    104101        public function load():void { 
     102                model.mediaHandler(video); 
    105103                if(stream.bytesLoaded != stream.bytesTotal) { 
    106104                        stream.close(); 
     
    123121                url += '&client='+encodeURI(model.config['client']); 
    124122                url += '&version='+encodeURI(model.config['version']); 
     123                url += '&width='+model.config['width']; 
    125124                if(getToken()) { url += '&token='+getToken(); } 
    126                 trace(url); 
    127125                stream.play(url); 
    128126                clearInterval(loadinterval); 
     
    136134        /** Interval for the loading progress **/ 
    137135        private function loadHandler():void { 
    138                 if(!timer) {  
    139                         timer = new Timer(2000,1); 
    140             timer.addEventListener("timer", timerHandler); 
    141             timer.start(); 
    142                 } 
    143136                loaded = stream.bytesLoaded; 
    144137                var ttl = stream.bytesTotal; 
     
    162155                                video.width = dat.width; 
    163156                                video.height = dat.height; 
    164                                 model.mediaHandler(video); 
    165                         } else { 
    166                                 model.mediaHandler(); 
    167157                        } 
    168158                        if(dat.seekpoints) { 
     
    244234                } else if(evt.info.code == "NetStream.Play.StreamNotFound") { 
    245235                        stop(); 
    246                         model.sendEvent(ModelEvent.ERROR,{message:"Video stream not found: " +  
     236                        model.sendEvent(ModelEvent.ERROR,{message:"Video stream not found: " + 
    247237                                model.playlist[model.config['item']]['file']}); 
    248238                } else {  
     
    274264                if(bfr<100 && pos < Math.abs(dur-stream.bufferTime*2)) { 
    275265                        model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 
    276                         if(model.config['state'] != ModelStates.BUFFERING  && bfr<50) { 
     266                        if(model.config['state'] != ModelStates.BUFFERING  && bfr < 10) { 
    277267                                model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 
    278268                        } 
    279269                } else if (model.config['state'] == ModelStates.BUFFERING) { 
    280270                        model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 
    281                         if(!keyframes) { 
    282                                 video.width = 320; 
    283                                 video.height = 240; 
    284                                 model.mediaHandler(video); 
    285                         } 
    286271                } 
    287272                if(dur > 0) { 
    288273                        model.sendEvent(ModelEvent.TIME,{position:pos,duration:dur}); 
    289274                } 
    290         }; 
    291  
    292  
    293         /** Timer that checks bandwidth has completed. **/ 
    294         public function timerHandler(event:TimerEvent):void { 
    295         var bww = Math.round(stream.bytesLoaded*4/1024); 
    296                 model.sendEvent(ModelEvent.META,{bandwidth:bww}); 
    297275        }; 
    298276 
Note: See TracChangeset for help on using the changeset viewer.