Changeset 88 for trunk/as3/com/jeroenwijering/models/HTTPModel.as
- Timestamp:
- 10/20/08 08:16:10 (5 years ago)
- File:
-
- 1 edited
-
trunk/as3/com/jeroenwijering/models/HTTPModel.as (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/as3/com/jeroenwijering/models/HTTPModel.as
r59 r88 1 1 /** 2 * Wrapper for playback of progressively downloadedvideo.2 * Wrapper for playback of http 'streaming' video. 3 3 **/ 4 4 package com.jeroenwijering.models { … … 16 16 import flash.utils.clearInterval; 17 17 import flash.utils.setInterval; 18 import flash.utils.Timer;19 18 20 19 … … 46 45 /** Byteposition to which the file has been loaded. **/ 47 46 private var loaded:Number; 48 /** Timer for checking bandwidth **/49 private var timer:Timer50 47 51 48 … … 103 100 /** Load content. **/ 104 101 public function load():void { 102 model.mediaHandler(video); 105 103 if(stream.bytesLoaded != stream.bytesTotal) { 106 104 stream.close(); … … 123 121 url += '&client='+encodeURI(model.config['client']); 124 122 url += '&version='+encodeURI(model.config['version']); 123 url += '&width='+model.config['width']; 125 124 if(getToken()) { url += '&token='+getToken(); } 126 trace(url);127 125 stream.play(url); 128 126 clearInterval(loadinterval); … … 136 134 /** Interval for the loading progress **/ 137 135 private function loadHandler():void { 138 if(!timer) {139 timer = new Timer(2000,1);140 timer.addEventListener("timer", timerHandler);141 timer.start();142 }143 136 loaded = stream.bytesLoaded; 144 137 var ttl = stream.bytesTotal; … … 162 155 video.width = dat.width; 163 156 video.height = dat.height; 164 model.mediaHandler(video);165 } else {166 model.mediaHandler();167 157 } 168 158 if(dat.seekpoints) { … … 244 234 } else if(evt.info.code == "NetStream.Play.StreamNotFound") { 245 235 stop(); 246 model.sendEvent(ModelEvent.ERROR,{message:"Video stream not found: " + 236 model.sendEvent(ModelEvent.ERROR,{message:"Video stream not found: " + 247 237 model.playlist[model.config['item']]['file']}); 248 238 } else { … … 274 264 if(bfr<100 && pos < Math.abs(dur-stream.bufferTime*2)) { 275 265 model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 276 if(model.config['state'] != ModelStates.BUFFERING && bfr <50) {266 if(model.config['state'] != ModelStates.BUFFERING && bfr < 10) { 277 267 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 278 268 } 279 269 } else if (model.config['state'] == ModelStates.BUFFERING) { 280 270 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 281 if(!keyframes) {282 video.width = 320;283 video.height = 240;284 model.mediaHandler(video);285 }286 271 } 287 272 if(dur > 0) { 288 273 model.sendEvent(ModelEvent.TIME,{position:pos,duration:dur}); 289 274 } 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});297 275 }; 298 276
Note: See TracChangeset
for help on using the changeset viewer.
