Changeset 149


Ignore:
Timestamp:
01/29/09 04:55:11 (4 years ago)
Author:
jeroen
Message:

fixed start offset, added expressinstall.swf and reinsterd plugins

Location:
trunk/as3
Files:
8 added
12 edited

Legend:

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

    r140 r149  
    4343        public function load(itm:Object):void { 
    4444                item = itm; 
    45                 position = item['start']; 
     45                position = 0; 
    4646                model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 
    4747                model.sendEvent(ModelEvent.BUFFER,{percentage:0}); 
     
    6565        /** Interval function that pings the position. **/ 
    6666        protected function positionInterval():void { 
    67                 position = Math.round(position*10+1)/10; 
    68                 if(position-item['start'] < item['duration']) { 
    69                         model.sendEvent(ModelEvent.TIME,{position:position-item['start'],duration:item['duration']}); 
     67                if(position < item['duration']) { 
     68                        model.sendEvent(ModelEvent.TIME,{position:position,duration:item['duration']}); 
    7069                } else if (item['duration'] > 0) { 
    7170                        pause(); 
     
    8281        public function seek(pos:Number):void { 
    8382                clearInterval(interval); 
    84                 position = item['start'] + pos; 
     83                position = pos; 
    8584                play(); 
    8685        }; 
     
    9089        public function stop():void { 
    9190                clearInterval(interval); 
    92                 if(item) {  
    93                         position = item['start']; 
    94                 } 
     91                position = 0; 
    9592                model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.IDLE}); 
    9693        }; 
  • trunk/as3/com/jeroenwijering/models/CameraModel.as

    r135 r149  
    6363 
    6464 
     65        /** Interval function that pings the position. **/ 
     66        override protected function positionInterval():void { 
     67                position += 0.1; 
     68                super.positionInterval(); 
     69        }; 
     70 
     71 
    6572        /** Destroy the videocamera. **/ 
    6673        override public function stop():void { 
  • trunk/as3/com/jeroenwijering/models/HTTPModel.as

    r135 r149  
    3939        /** Boolean for mp4 / flv streaming. **/ 
    4040        protected var mp4:Boolean; 
     41        /** Load offset for bandwidth checking. **/ 
     42        protected var loadtimer:Number; 
    4143 
    4244 
     
    99101 
    100102 
    101         /** Returns a key to add to the stream. **/ 
    102         protected function getToken():String { 
    103                 return model.config['token']; 
    104         }; 
    105  
    106  
    107103        /** Create the video request URL. **/ 
    108104        protected function getURL():String { 
     
    116112                        url += '&start='+byteoffset; 
    117113                } 
    118                 if(getToken()) { 
    119                         url += '&token='+getToken(); 
    120                 } 
    121114                return url; 
    122115        }; 
     
    143136                var ttl:Number = stream.bytesTotal + byteoffset; 
    144137                var off:Number = byteoffset; 
    145                 if(meta) { 
    146                         ttl = getOffset(item['start']+item['duration']) - getOffset(item['start']); 
    147                         off = Math.max(0,byteoffset-getOffset(item['start'])); 
    148                 } 
     138                model.sendEvent(ModelEvent.LOADED,{loaded:ldd,total:ttl,offset:off}); 
    149139                if(ldd+off >= ttl && ldd > 0) { 
    150                         model.sendEvent(ModelEvent.LOADED,{loaded:ttl-off,total:ttl,offset:off}); 
    151140                        clearInterval(loadinterval); 
    152                 } else { 
    153                         model.sendEvent(ModelEvent.LOADED,{loaded:ldd,total:ttl,offset:off}); 
    154                 } 
     141                } 
     142                if(!loadtimer) { 
     143                        loadtimer = setTimeout(loadTimeout,3000); 
     144                } 
     145        }; 
     146 
     147 
     148        /** timeout for checking the bitrate. **/ 
     149        protected function loadTimeout():void { 
     150                var obj:Object = new Object(); 
     151                obj['bandwidth'] = Math.round(stream.bytesLoaded/1024/3*8); 
     152                if(item['duration']) { 
     153                        obj['bitrate'] = Math.round(stream.bytesTotal/1024*8/item['duration']); 
     154                } 
     155                model.sendEvent('META',obj); 
    155156        }; 
    156157 
     
    161162                        video.width = dat.width; 
    162163                        video.height = dat.height; 
    163                 } 
    164                 if(dat.duration) {  
    165                         dat.duration -= item['start']; 
    166164                } 
    167165                if(dat['type'] == 'metadata' && !meta) { 
     
    175173                        } 
    176174                        if(item['start'] > 0) { 
    177                                 seek(0); 
     175                                seek(item['start']); 
    178176                        } 
    179177                } 
     
    198196        /** Interval for the position progress **/ 
    199197        override protected function positionInterval():void { 
    200                 var pos:Number = Math.round(stream.time*10)/10; 
     198                position = Math.round(stream.time*10)/10; 
    201199                if (mp4) {  
    202                         pos += timeoffset; 
     200                        position += timeoffset; 
    203201                } 
    204202                var bfr:Number = Math.round(stream.bufferLength/stream.bufferTime*100); 
    205                 if(bfr < 95 && pos < Math.abs(item['duration']-stream.bufferTime-1)) { 
     203                if(bfr < 95 && position < Math.abs(item['duration']-stream.bufferTime-1)) { 
    206204                        model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 
    207205                        if(model.config['state'] != ModelStates.BUFFERING && bfr < 25) { 
     
    211209                        model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 
    212210                } 
    213                 if(pos-item['start'] < item['duration']) { 
    214                         if(pos > 0) { 
    215                                 position = Math.max(0,Math.round((pos-item['start'])*10)/10); 
    216                                 model.sendEvent(ModelEvent.TIME,{position:position,duration:item['duration']}); 
    217                         } 
    218                 } else if (item['duration'] > 0) { 
    219                         pause(); 
    220                         model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.COMPLETED}); 
    221                 } 
     211                super.positionInterval(); 
    222212        }; 
    223213 
     
    225215        /** Seek to a specific second. **/ 
    226216        override public function seek(pos:Number):void { 
    227                 var off = getOffset(pos+item['start']); 
     217                var off:Number = getOffset(pos); 
    228218                if(off < byteoffset || off > byteoffset+stream.bytesLoaded) { 
    229                         timeoffset = getOffset(pos+item['start'],true); 
     219                        timeoffset = getOffset(pos,true); 
    230220                        byteoffset = off; 
    231221                        load(item); 
    232222                } else { 
    233223                        super.seek(pos); 
    234                         if(mp4) {  
     224                        if(mp4) { 
    235225                                stream.seek(position-timeoffset); 
    236226                        } else { 
  • trunk/as3/com/jeroenwijering/models/ImageModel.as

    r135 r149  
    5858 
    5959 
     60        /** Interval function that pings the position. **/ 
     61        override protected function positionInterval():void { 
     62                position += 0.1; 
     63                super.positionInterval(); 
     64        }; 
     65 
     66 
    6067        /** Send load progress to player. **/ 
    6168        private function progressHandler(evt:ProgressEvent):void { 
  • trunk/as3/com/jeroenwijering/models/LighttpdModel.as

    r135 r149  
    3838                url += '&version='+encodeURI(model.config['version']); 
    3939                url += '&width='+model.config['width']; 
    40                 if(getToken()) { 
    41                         url += '&token='+getToken(); 
    42                 } 
    4340                return url; 
    4441        }; 
  • trunk/as3/com/jeroenwijering/models/NginxModel.as

    r135 r149  
    2929                        url += '?start='+byteoffset; 
    3030                } 
    31                 if(getToken()) { 
    32                         url += '&token='+getToken(); 
    33                 } 
    3431                return url; 
    3532        }; 
  • trunk/as3/com/jeroenwijering/models/RTMPModel.as

    r143 r149  
    3232        /** Sound control object. **/ 
    3333        protected var transform:SoundTransform; 
     34        /** Save that the video has been started. **/ 
     35        protected var started:Boolean; 
    3436 
    3537 
     
    8688                        video.height = dat.height; 
    8789                } 
    88                 if(dat.duration) {  
    89                         dat.duration -= item['start']; 
    90                 }  
    9190                if(dat.type == 'complete') { 
    9291                        clearInterval(interval); 
     
    123122                        model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 
    124123                } 
    125                 if(position < item['duration']) { 
    126                         model.sendEvent(ModelEvent.TIME,{position:position,duration:item['duration']}); 
    127                 } else if (item['duration'] > 0) { 
    128                         pause(); 
    129                         model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.COMPLETED}); 
    130                 } 
     124                super.positionInterval(); 
    131125        }; 
    132126 
     
    150144                model.config['mute'] == true ? volume(0): volume(model.config['volume']); 
    151145                interval = setInterval(positionInterval,100); 
    152                 if(item['start'] > 0) { 
    153                         stream.play(getID(item['file']),item['start']); 
    154                 } else { 
    155                         stream.play(getID(item['file'])); 
    156                 } 
     146                stream.play(getID(item['file'])); 
    157147        }; 
    158148 
     
    170160                                } 
    171161                                break; 
     162                        case  'NetStream.Play.Start': 
     163                                if(item['start'] > 0 && !started) { 
     164                                        seek(item['start']); 
     165                                } 
     166                                started = true; 
     167                                break; 
    172168                        case  'NetStream.Seek.Notify': 
    173169                                clearInterval(interval); 
     
    201197                connection.close(); 
    202198                super.stop(); 
     199                started = false; 
    203200        }; 
    204201 
     
    206203        /** Get the streamlength returned from the connection. **/ 
    207204        private function streamlengthHandler(len:Number):void { 
    208                 onData({type:'streamlength',duration:len-item['start']}); 
     205                onData({type:'streamlength',duration:len}); 
    209206        }; 
    210207 
  • trunk/as3/com/jeroenwijering/models/SoundModel.as

    r135 r149  
    7676                sound.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); 
    7777                sound.addEventListener(ProgressEvent.PROGRESS,progressHandler); 
    78                 sound.addEventListener(Event.COMPLETE,loadedHandler); 
    7978                sound.addEventListener(Event.ID3,id3Handler); 
    8079                sound.load(new URLRequest(item['file']),context); 
    8180                play(); 
    82         }; 
    83  
    84  
    85         /** Sound has been loaded, so the final duration is known. **/ 
    86         private function loadedHandler(evt:Event):void { 
    87                 model.sendEvent(ModelEvent.META,{duration:sound.length/1000-item['start']}); 
     81                if(item['start'] > 0) { 
     82                        seek(item['start']); 
     83                } 
    8884        }; 
    8985 
     
    117113                        model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 
    118114                } 
    119                 if(position-item['start'] < item['duration']) { 
    120                         model.sendEvent(ModelEvent.TIME,{position:position-item['start'],duration:item['duration']}); 
    121                 } else if(item['duration'] > 0) { 
    122                         pause(); 
    123                         model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.COMPLETED}); 
    124                 } 
     115                super.positionInterval(); 
    125116        }; 
    126117 
     
    131122                var ttl = evt.bytesTotal; 
    132123                model.sendEvent(ModelEvent.LOADED,{loaded:ldd,total:ttl}); 
     124                if(ldd/ttl > 0.1 && item['duration'] == 0) { 
     125                        model.sendEvent(ModelEvent.META,{duration:sound.length/1000/ldd*ttl}); 
     126                } 
    133127        }; 
    134128 
  • trunk/as3/com/jeroenwijering/models/VideoModel.as

    r135 r149  
    2929        /** Interval ID for the loading. **/ 
    3030        protected var loadinterval:Number; 
     31        /** Load offset for bandwidth checking. **/ 
     32        protected var loadtimer:Number; 
    3133 
    3234 
     
    7577                        clearInterval(loadinterval); 
    7678                } 
     79                if(!loadtimer) { 
     80                        loadtimer = setTimeout(loadTimeout,3000); 
     81                } 
     82        }; 
     83 
     84 
     85        /** timeout for checking the bitrate. **/ 
     86        protected function loadTimeout():void { 
     87                var obj:Object = new Object(); 
     88                obj['bandwidth'] = Math.round(stream.bytesLoaded/1024/3*8); 
     89                if(item['duration']) { 
     90                        obj['bitrate'] = Math.round(stream.bytesTotal/1024*8/item['duration']); 
     91                } 
     92                model.sendEvent('META',obj); 
    7793        }; 
    7894 
     
    8399                        video.width = dat.width; 
    84100                        video.height = dat.height; 
    85                 } 
    86                 if(dat.duration) {  
    87                         dat.duration -= item['start']; 
    88101                } 
    89102                model.sendEvent(ModelEvent.META,dat); 
     
    117130                        model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 
    118131                } 
    119                 if(position-item['start'] < item['duration']) { 
    120                         var pos:Number = Math.max(0,Math.round((position-item['start'])*10)/10); 
    121                         model.sendEvent(ModelEvent.TIME,{position:pos,duration:item['duration']}); 
    122                 } else if (item['duration'] > 0) { 
    123                         pause(); 
    124                         model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.COMPLETED}); 
    125                 } 
     132                super.positionInterval(); 
    126133        }; 
    127134 
     
    156163                stream.close(); 
    157164                clearInterval(loadinterval); 
     165                loadtimer = undefined; 
    158166                super.stop(); 
    159167        }; 
  • trunk/as3/com/jeroenwijering/models/YoutubeModel.as

    r140 r149  
    5959                inbound.addEventListener(StatusEvent.STATUS,onLocalConnectionStatusChange); 
    6060                inbound.client = this; 
    61                 inbound.connect('AS2_'+unique); 
    6261                loader = new Loader(); 
    6362                loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); 
     
    10099                                model.mediaHandler(loader); 
    101100                        } 
    102                 } else {  
     101                } else { 
     102                        inbound.connect('AS2_'+unique); 
    103103                        loader.load(new URLRequest(location)); 
    104104                } 
  • trunk/as3/com/jeroenwijering/player/Player.as

    r148 r149  
    2727                link:undefined, 
    2828                start:0, 
     29                streamer:undefined, 
    2930                tags:undefined, 
    3031                title:undefined, 
     
    6566                linktarget:'_blank', 
    6667                plugins:undefined, 
    67                 streamer:undefined, 
    6868                token:undefined, 
    6969                tracecall:'arthropod', 
    70                 version:'4.4.143' 
     70                version:'4.4.148' 
    7171        }; 
    7272        /** Base directory from which all plugins are loaded. **/ 
     
    129129                model.loadModel(new ImageModel(model),'image'); 
    130130                model.loadModel(new LighttpdModel(model),'lighttpd'); 
    131                 model.loadModel(new NginxModel(model),'nginx'); 
     131                // model.loadModel(new NginxModel(model),'nginx'); 
    132132                model.loadModel(new RTMPModel(model),'rtmp'); 
    133133                model.loadModel(new SoundModel(model),'sound'); 
Note: See TracChangeset for help on using the changeset viewer.