Changeset 149
- Timestamp:
- 01/29/09 04:55:11 (4 years ago)
- Location:
- trunk/as3
- Files:
-
- 8 added
- 12 edited
-
com/jeroenwijering/models/BasicModel.as (modified) (4 diffs)
-
com/jeroenwijering/models/CameraModel.as (modified) (1 diff)
-
com/jeroenwijering/models/HTTPModel.as (modified) (9 diffs)
-
com/jeroenwijering/models/ImageModel.as (modified) (1 diff)
-
com/jeroenwijering/models/LighttpdModel.as (modified) (1 diff)
-
com/jeroenwijering/models/NginxModel.as (modified) (1 diff)
-
com/jeroenwijering/models/RTMPModel.as (modified) (7 diffs)
-
com/jeroenwijering/models/SoundModel.as (modified) (3 diffs)
-
com/jeroenwijering/models/VideoModel.as (modified) (5 diffs)
-
com/jeroenwijering/models/YoutubeModel.as (modified) (2 diffs)
-
com/jeroenwijering/player/Player.as (modified) (3 diffs)
-
com/jeroenwijering/plugins/Accessibility.as (added)
-
com/jeroenwijering/plugins/ClickProxy.as (added)
-
com/jeroenwijering/plugins/HD.as (added)
-
com/jeroenwijering/plugins/MetaViewer.as (added)
-
com/jeroenwijering/plugins/Revolt.as (added)
-
com/jeroenwijering/plugins/SoundProxy.as (added)
-
com/jeroenwijering/plugins/Yousearch.as (added)
-
expressInstall.swf (added)
-
player.swf (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/as3/com/jeroenwijering/models/BasicModel.as
r140 r149 43 43 public function load(itm:Object):void { 44 44 item = itm; 45 position = item['start'];45 position = 0; 46 46 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 47 47 model.sendEvent(ModelEvent.BUFFER,{percentage:0}); … … 65 65 /** Interval function that pings the position. **/ 66 66 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']}); 70 69 } else if (item['duration'] > 0) { 71 70 pause(); … … 82 81 public function seek(pos:Number):void { 83 82 clearInterval(interval); 84 position = item['start'] +pos;83 position = pos; 85 84 play(); 86 85 }; … … 90 89 public function stop():void { 91 90 clearInterval(interval); 92 if(item) { 93 position = item['start']; 94 } 91 position = 0; 95 92 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.IDLE}); 96 93 }; -
trunk/as3/com/jeroenwijering/models/CameraModel.as
r135 r149 63 63 64 64 65 /** Interval function that pings the position. **/ 66 override protected function positionInterval():void { 67 position += 0.1; 68 super.positionInterval(); 69 }; 70 71 65 72 /** Destroy the videocamera. **/ 66 73 override public function stop():void { -
trunk/as3/com/jeroenwijering/models/HTTPModel.as
r135 r149 39 39 /** Boolean for mp4 / flv streaming. **/ 40 40 protected var mp4:Boolean; 41 /** Load offset for bandwidth checking. **/ 42 protected var loadtimer:Number; 41 43 42 44 … … 99 101 100 102 101 /** Returns a key to add to the stream. **/102 protected function getToken():String {103 return model.config['token'];104 };105 106 107 103 /** Create the video request URL. **/ 108 104 protected function getURL():String { … … 116 112 url += '&start='+byteoffset; 117 113 } 118 if(getToken()) {119 url += '&token='+getToken();120 }121 114 return url; 122 115 }; … … 143 136 var ttl:Number = stream.bytesTotal + byteoffset; 144 137 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}); 149 139 if(ldd+off >= ttl && ldd > 0) { 150 model.sendEvent(ModelEvent.LOADED,{loaded:ttl-off,total:ttl,offset:off});151 140 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); 155 156 }; 156 157 … … 161 162 video.width = dat.width; 162 163 video.height = dat.height; 163 }164 if(dat.duration) {165 dat.duration -= item['start'];166 164 } 167 165 if(dat['type'] == 'metadata' && !meta) { … … 175 173 } 176 174 if(item['start'] > 0) { 177 seek( 0);175 seek(item['start']); 178 176 } 179 177 } … … 198 196 /** Interval for the position progress **/ 199 197 override protected function positionInterval():void { 200 var pos:Number= Math.round(stream.time*10)/10;198 position = Math.round(stream.time*10)/10; 201 199 if (mp4) { 202 pos += timeoffset;200 position += timeoffset; 203 201 } 204 202 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)) { 206 204 model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 207 205 if(model.config['state'] != ModelStates.BUFFERING && bfr < 25) { … … 211 209 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 212 210 } 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(); 222 212 }; 223 213 … … 225 215 /** Seek to a specific second. **/ 226 216 override public function seek(pos:Number):void { 227 var off = getOffset(pos+item['start']);217 var off:Number = getOffset(pos); 228 218 if(off < byteoffset || off > byteoffset+stream.bytesLoaded) { 229 timeoffset = getOffset(pos +item['start'],true);219 timeoffset = getOffset(pos,true); 230 220 byteoffset = off; 231 221 load(item); 232 222 } else { 233 223 super.seek(pos); 234 if(mp4) { 224 if(mp4) { 235 225 stream.seek(position-timeoffset); 236 226 } else { -
trunk/as3/com/jeroenwijering/models/ImageModel.as
r135 r149 58 58 59 59 60 /** Interval function that pings the position. **/ 61 override protected function positionInterval():void { 62 position += 0.1; 63 super.positionInterval(); 64 }; 65 66 60 67 /** Send load progress to player. **/ 61 68 private function progressHandler(evt:ProgressEvent):void { -
trunk/as3/com/jeroenwijering/models/LighttpdModel.as
r135 r149 38 38 url += '&version='+encodeURI(model.config['version']); 39 39 url += '&width='+model.config['width']; 40 if(getToken()) {41 url += '&token='+getToken();42 }43 40 return url; 44 41 }; -
trunk/as3/com/jeroenwijering/models/NginxModel.as
r135 r149 29 29 url += '?start='+byteoffset; 30 30 } 31 if(getToken()) {32 url += '&token='+getToken();33 }34 31 return url; 35 32 }; -
trunk/as3/com/jeroenwijering/models/RTMPModel.as
r143 r149 32 32 /** Sound control object. **/ 33 33 protected var transform:SoundTransform; 34 /** Save that the video has been started. **/ 35 protected var started:Boolean; 34 36 35 37 … … 86 88 video.height = dat.height; 87 89 } 88 if(dat.duration) {89 dat.duration -= item['start'];90 }91 90 if(dat.type == 'complete') { 92 91 clearInterval(interval); … … 123 122 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 124 123 } 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(); 131 125 }; 132 126 … … 150 144 model.config['mute'] == true ? volume(0): volume(model.config['volume']); 151 145 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'])); 157 147 }; 158 148 … … 170 160 } 171 161 break; 162 case 'NetStream.Play.Start': 163 if(item['start'] > 0 && !started) { 164 seek(item['start']); 165 } 166 started = true; 167 break; 172 168 case 'NetStream.Seek.Notify': 173 169 clearInterval(interval); … … 201 197 connection.close(); 202 198 super.stop(); 199 started = false; 203 200 }; 204 201 … … 206 203 /** Get the streamlength returned from the connection. **/ 207 204 private function streamlengthHandler(len:Number):void { 208 onData({type:'streamlength',duration:len -item['start']});205 onData({type:'streamlength',duration:len}); 209 206 }; 210 207 -
trunk/as3/com/jeroenwijering/models/SoundModel.as
r135 r149 76 76 sound.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); 77 77 sound.addEventListener(ProgressEvent.PROGRESS,progressHandler); 78 sound.addEventListener(Event.COMPLETE,loadedHandler);79 78 sound.addEventListener(Event.ID3,id3Handler); 80 79 sound.load(new URLRequest(item['file']),context); 81 80 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 } 88 84 }; 89 85 … … 117 113 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 118 114 } 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(); 125 116 }; 126 117 … … 131 122 var ttl = evt.bytesTotal; 132 123 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 } 133 127 }; 134 128 -
trunk/as3/com/jeroenwijering/models/VideoModel.as
r135 r149 29 29 /** Interval ID for the loading. **/ 30 30 protected var loadinterval:Number; 31 /** Load offset for bandwidth checking. **/ 32 protected var loadtimer:Number; 31 33 32 34 … … 75 77 clearInterval(loadinterval); 76 78 } 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); 77 93 }; 78 94 … … 83 99 video.width = dat.width; 84 100 video.height = dat.height; 85 }86 if(dat.duration) {87 dat.duration -= item['start'];88 101 } 89 102 model.sendEvent(ModelEvent.META,dat); … … 117 130 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 118 131 } 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(); 126 133 }; 127 134 … … 156 163 stream.close(); 157 164 clearInterval(loadinterval); 165 loadtimer = undefined; 158 166 super.stop(); 159 167 }; -
trunk/as3/com/jeroenwijering/models/YoutubeModel.as
r140 r149 59 59 inbound.addEventListener(StatusEvent.STATUS,onLocalConnectionStatusChange); 60 60 inbound.client = this; 61 inbound.connect('AS2_'+unique);62 61 loader = new Loader(); 63 62 loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); … … 100 99 model.mediaHandler(loader); 101 100 } 102 } else { 101 } else { 102 inbound.connect('AS2_'+unique); 103 103 loader.load(new URLRequest(location)); 104 104 } -
trunk/as3/com/jeroenwijering/player/Player.as
r148 r149 27 27 link:undefined, 28 28 start:0, 29 streamer:undefined, 29 30 tags:undefined, 30 31 title:undefined, … … 65 66 linktarget:'_blank', 66 67 plugins:undefined, 67 streamer:undefined,68 68 token:undefined, 69 69 tracecall:'arthropod', 70 version:'4.4.14 3'70 version:'4.4.148' 71 71 }; 72 72 /** Base directory from which all plugins are loaded. **/ … … 129 129 model.loadModel(new ImageModel(model),'image'); 130 130 model.loadModel(new LighttpdModel(model),'lighttpd'); 131 model.loadModel(new NginxModel(model),'nginx');131 // model.loadModel(new NginxModel(model),'nginx'); 132 132 model.loadModel(new RTMPModel(model),'rtmp'); 133 133 model.loadModel(new SoundModel(model),'sound');
Note: See TracChangeset
for help on using the changeset viewer.
