Changeset 6
- Timestamp:
- 06/09/08 08:34:58 (5 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 15 edited
-
as3/com/jeroenwijering/models/HTTPModel.as (modified) (2 diffs)
-
as3/com/jeroenwijering/models/RTMPModel.as (modified) (7 diffs)
-
as3/com/jeroenwijering/models/SoundModel.as (modified) (2 diffs)
-
as3/com/jeroenwijering/models/VideoModel.as (modified) (1 diff)
-
as3/com/jeroenwijering/player/Controller.as (modified) (11 diffs)
-
as3/com/jeroenwijering/player/Model.as (modified) (4 diffs)
-
as3/com/jeroenwijering/player/Player.as (modified) (3 diffs)
-
as3/com/jeroenwijering/utils/Animations.as (modified) (2 diffs)
-
as3/com/jeroenwijering/utils/Skinner.as (modified) (4 diffs)
-
as3/com/jeroenwijering/utils/Stacker.as (modified) (2 diffs)
-
as3/com/jeroenwijering/views/ControlbarView.as (modified) (6 diffs)
-
as3/com/jeroenwijering/views/PlaylistView.as (modified) (3 diffs)
-
as3/player.fla (modified) (previous)
-
as3/player.swf (modified) (previous)
-
misc/blacktube.fla (modified) (previous)
-
misc/blacktube.swf (added)
-
misc/bright.fla (added)
-
misc/inverted.fla (added)
-
misc/inverted.swf (added)
-
misc/stylish.swf (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/as3/com/jeroenwijering/models/HTTPModel.as
r5 r6 241 241 private function statusHandler(evt:NetStatusEvent) { 242 242 if(evt.info.code == "NetStream.Play.Stop") { 243 if(model. state== ModelStates.COMPLETED) {243 if(model.config['state'] == ModelStates.COMPLETED) { 244 244 stream.close(); 245 245 } else { … … 273 273 if(bfr < 100 && pos < Math.abs(dur-stream.bufferTime-1)) { 274 274 model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 275 if(model. state!= ModelStates.BUFFERING) {275 if(model.config['state'] != ModelStates.BUFFERING) { 276 276 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 277 277 } 278 } else if (model. state== ModelStates.BUFFERING) {278 } else if (model.config['state'] == ModelStates.BUFFERING) { 279 279 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 280 280 } -
trunk/as3/com/jeroenwijering/models/RTMPModel.as
r1 r6 12 12 import flash.media.*; 13 13 import flash.net.*; 14 import flash.utils.clearInterval; 15 import flash.utils.setInterval; 14 import flash.utils.*; 16 15 17 16 … … 31 30 /** Interval ID for the time. **/ 32 31 private var timeinterval:Number; 32 /** Timeout ID for cleaning up idle streams. **/ 33 private var timeout:Number; 33 34 /** Metadata received switch. **/ 34 35 private var metadata:Boolean; … … 168 169 stream.pause(); 169 170 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PAUSED}); 171 timeout = setTimeout(stop,10000); 170 172 }; 171 173 … … 173 175 /** Resume playing. **/ 174 176 public function play() { 177 clearTimeout(timeout); 175 178 stream.resume(); 176 179 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); … … 194 197 public function seek(pos:Number) { 195 198 clearInterval(timeinterval); 196 if(model. state== ModelStates.PAUSED) {199 if(model.config['state'] == ModelStates.PAUSED) { 197 200 stream.resume(); 198 201 } … … 233 236 234 237 235 /** Destroy the videocamera. **/238 /** Destroy the stream. **/ 236 239 public function stop() { 237 240 clearInterval(timeinterval); … … 250 253 if(bfr < 100 && pos < dur-stream.bufferTime-1) { 251 254 model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 252 if(model. state!= ModelStates.BUFFERING) {255 if(model.config['state'] != ModelStates.BUFFERING) { 253 256 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 254 257 } 255 } else if (model. state== ModelStates.BUFFERING) {258 } else if (model.config['state'] == ModelStates.BUFFERING) { 256 259 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 257 260 } -
trunk/as3/com/jeroenwijering/models/SoundModel.as
r1 r6 145 145 var dur = Math.round(sound.length*sound.bytesTotal/sound.bytesLoaded/100)/10; 146 146 if(sound.isBuffering == true) { 147 if(model. state!= ModelStates.BUFFERING) {147 if(model.config['state'] != ModelStates.BUFFERING) { 148 148 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 149 149 } else { … … 151 151 model.sendEvent(ModelEvent.BUFFER,{percentage:pct}); 152 152 } 153 } else if (model. state== ModelStates.BUFFERING && sound.isBuffering == false) {153 } else if (model.config['state'] == ModelStates.BUFFERING && sound.isBuffering == false) { 154 154 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 155 155 } -
trunk/as3/com/jeroenwijering/models/VideoModel.as
r1 r6 192 192 if(bfr < 100 && pos < dur-stream.bufferTime-1) { 193 193 model.sendEvent(ModelEvent.BUFFER,{percentage:bfr}); 194 if(model. state!= ModelStates.BUFFERING) {194 if(model.config['state'] != ModelStates.BUFFERING) { 195 195 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.BUFFERING}); 196 196 } 197 } else if (model. state== ModelStates.BUFFERING) {197 } else if (model.config['state'] == ModelStates.BUFFERING) { 198 198 model.sendEvent(ModelEvent.STATE,{newstate:ModelStates.PLAYING}); 199 199 } -
trunk/as3/com/jeroenwijering/player/Controller.as
r3 r6 5 5 6 6 7 import flash.display.MovieClip;8 import flash.events.*;9 import flash.net.*;10 7 import com.jeroenwijering.events.*; 11 8 import com.jeroenwijering.player.*; 12 9 import com.jeroenwijering.utils.*; 10 import flash.display.MovieClip; 11 import flash.events.*; 12 import flash.geom.Rectangle; 13 import flash.net.*; 14 import flash.system.Capabilities; 13 15 14 16 … … 28 30 /** object that povides randomization. **/ 29 31 private var randomizer:Randomizer; 30 /** save the state of the model. **/31 private var state:String;32 32 33 33 … … 39 39 skin.stage.align = "TL"; 40 40 skin.stage.addEventListener(Event.RESIZE,resizeHandler); 41 skin.stage.addEventListener(Event.FULLSCREEN,resizeHandler);42 41 playlister = new Playlister(); 43 42 playlister.addEventListener(Event.COMPLETE,playlistHandler); … … 49 48 public function start(mdl:Model,vie:View) { 50 49 model= mdl; 51 model.addEventListener(ModelEvent.STATE,stateHandler);52 50 model.addEventListener(ModelEvent.META,metaHandler); 53 51 model.addEventListener(ModelEvent.TIME,metaHandler); … … 94 92 skin.stage.displayState = 'normal'; 95 93 } else { 94 skin.stage["fullScreenSourceRect"] = new Rectangle(0,0, 95 Capabilities.screenResolutionX,Capabilities.screenResolutionY); 96 96 skin.stage.displayState = 'fullScreen'; 97 97 } … … 101 101 /** Jump to a userdefined item in the playlist. **/ 102 102 private function itemHandler(evt:ViewEvent) { 103 if(playlist[config['item']]['author'] == 'commercial') { return; } 103 104 var itm = evt.data.index; 104 105 if (itm < 0) { … … 163 164 /** Jump to the next item in the playlist. **/ 164 165 private function nextHandler(evt:ViewEvent) { 166 if(playlist[config['item']]['author'] == 'commercial') { return; } 165 167 if(config['shuffle'] == true) { 166 168 playItem(randomizer.pick()); … … 177 179 if(evt.data.state) { 178 180 dispatchEvent(new ControllerEvent(ControllerEvent.PLAY,{state:evt.data.state})); 179 } else if( state == ModelStates.PLAYING || state== ModelStates.BUFFERING) {181 } else if(config['state'] == ModelStates.PLAYING || config['state'] == ModelStates.BUFFERING) { 180 182 dispatchEvent(new ControllerEvent(ControllerEvent.PLAY,{state:false})); 181 183 } else { … … 211 213 /** Jump to the previous item in the playlist. **/ 212 214 private function prevHandler(evt:ViewEvent) { 215 if(playlist[config['item']]['author'] == 'commercial') { return; } 213 216 if(config['shuffle'] == true) { 214 217 playItem(randomizer.back()); … … 261 264 /** Seek to a specific part in a mediafile. **/ 262 265 private function seekHandler(evt:ViewEvent) { 266 if(playlist[config['item']]['author'] == 'commercial') { return; } 263 267 var pos = evt.data.position; 264 268 if(pos < 2) { pos = 0; } … … 277 281 /** Manage playback state changes **/ 278 282 private function stateHandler(evt:ModelEvent) { 279 state = evt.data.newstate;280 283 if(evt.data.newstate == ModelStates.COMPLETED && (config['repeat'] == true || 281 284 (config['shuffle'] == true && randomizer.length > 0) || -
trunk/as3/com/jeroenwijering/player/Model.as
r5 r6 27 27 /** Currently active model. **/ 28 28 private var current:Object; 29 /** Current playback state **/30 public var state:String;31 29 /** Loader for the preview image. **/ 32 30 private var loader:Loader; … … 123 121 private function playHandler(evt:ControllerEvent) { 124 122 if(evt.data.state == true) { 125 if( state== ModelStates.IDLE) {123 if(config['state'] == ModelStates.IDLE) { 126 124 current.load(); 127 } else if( state!= ModelStates.PAUSED) {125 } else if(config['state'] != ModelStates.PAUSED) { 128 126 current.seek(playlist[config['item']]['start']); 129 127 } else { … … 151 149 /** Seek inside a file. **/ 152 150 private function seekHandler(evt:ControllerEvent) { 153 if( state!= ModelStates.IDLE) {151 if(config['state'] != ModelStates.IDLE) { 154 152 current.seek(evt.data.position); 155 153 } … … 166 164 /** Dispatch events. State switch is saved. **/ 167 165 public function sendEvent(typ:String,dat:Object) { 168 if(typ == ModelEvent.STATE && dat.newstate != state) {169 dat.oldstate = state;170 state= dat.newstate;166 if(typ == ModelEvent.STATE && dat.newstate != config['state']) { 167 dat.oldstate = config['state']; 168 config['state'] = dat.newstate; 171 169 dispatchEvent(new ModelEvent(typ,dat)); 172 170 } else if (typ != ModelEvent.STATE) { -
trunk/as3/com/jeroenwijering/player/Player.as
r5 r6 48 48 49 49 abouttext:"About JW Player 4.0...", 50 aboutlink:"http://www.jeroenwijering.com/?page= about",50 aboutlink:"http://www.jeroenwijering.com/?page=player", 51 51 linktarget:'_self', 52 52 streamscript:undefined, … … 56 56 controlbarheight:20, 57 57 height:300, 58 state: 'IDLE',59 version:'4.0 r 3',58 state:undefined, 59 version:'4.0 r4', 60 60 width:400 61 61 }; … … 72 72 73 73 74 /** Constructor; Loads config . **/74 /** Constructor; Loads config parameters. **/ 75 75 public function Player() { 76 76 configger = new Configger(this); -
trunk/as3/com/jeroenwijering/utils/Animations.as
r5 r6 25 25 * @param spd The amount of alpha change per frame. 26 26 **/ 27 public static function fade(tgt:MovieClip,end:Number ,spd:Number=undefined) {27 public static function fade(tgt:MovieClip,end:Number=undefined,spd:Number=undefined) { 28 28 if(arguments.length > 2) { 29 Animations.speed = spd; 29 tgt.speed = spd; 30 } else { 31 tgt.speed = Animations.speed; 30 32 } 31 33 if(arguments.length > 1) { 32 Animations.end = end; 34 tgt.end = end; 35 } else { 36 tgt.end = Animations.end; 33 37 } 34 if(tgt.alpha > Animations.end) {35 Animations.speed = -Math.abs(Animations.speed);38 if(tgt.alpha > tgt.end) { 39 tgt.speed = -Math.abs(tgt.speed); 36 40 } else { 37 Animations.speed = Math.abs(Animations.speed);41 tgt.speed = Math.abs(tgt.speed); 38 42 } 39 tgt.visible = true;40 43 tgt.addEventListener(Event.ENTER_FRAME,fadeHandler); 41 44 }; … … 45 48 private static function fadeHandler(evt:Event) { 46 49 var tgt = MovieClip(evt.target); 47 if((tgt.alpha >= Animations.end && Animations.speed > 0) ||48 (tgt.alpha <= Animations.end && Animations.speed < 0)) {50 if((tgt.alpha >= tgt.end && tgt.speed > 0) || 51 (tgt.alpha <= tgt.end && tgt.speed < 0)) { 49 52 tgt.removeEventListener(Event.ENTER_FRAME,fadeHandler); 50 tgt.alpha = Animations.end;51 if( Animations.end == 0) {53 tgt.alpha = tgt.end; 54 if(tgt.end == 0) { 52 55 tgt.visible = false; 53 56 } 54 57 } else { 55 tgt.alpha += Animations.speed; 58 tgt.visible = true; 59 tgt.alpha += tgt.speed; 56 60 } 57 61 }; -
trunk/as3/com/jeroenwijering/utils/Skinner.as
r3 r6 7 7 8 8 9 import com.jeroenwijering.utils.Draw; 9 10 import flash.display.Loader; 10 11 import flash.display.MovieClip; … … 29 30 * Constructor. 30 31 * 31 * @param skn The MovieClip that contains the display, playlist and controlbar.32 * @param skn The player instance. 32 33 **/ 33 34 public function Skinner(ply:MovieClip) { … … 52 53 } 53 54 } else { 54 skin = player ['player'];55 skin = player.root['player']; 55 56 dispatchEvent(new Event(Event.COMPLETE)); 56 57 } … … 66 67 /** SWF loading completed; add to stage and populate. **/ 67 68 private function loaderHandler(evt:Event) { 68 var cnt = MovieClip(loader.content); 69 if(loader.content['player']) { 70 skin = MovieClip(loader.content['player']); 71 trace(loader.content['player']); 72 } else { 73 skin = MovieClip(loader.content); 74 } 75 Draw.clear(player); 76 player.addChild(skin); 69 77 /* 70 78 for(var i=0; i<cnt.numChildren; i++) { -
trunk/as3/com/jeroenwijering/utils/Stacker.as
r4 r6 47 47 48 48 /** Check if an child overlaps with others. **/ 49 private function overlaps() { 50 // working on this... 49 private function overlaps(idx:Number):Boolean { 50 var min = stack[idx].x; 51 var max = stack[idx].x+stack[idx].w; 52 for (var i in stack) { 53 if(i!=idx && stack[i].c.visible==true && stack[i].n!='back' && 54 stack[i].x < max && stack[i].x+stack[i].w > min) { 55 return true; 56 } 57 } 58 return false; 51 59 }; 52 60 … … 61 69 var rdf = latest-width; 62 70 var ldf = 0; 71 // first run through the entire stack, closing the gaps. 63 72 for(var i=0; i<stack.length; i++) { 64 if(stack[i].x > stack[0].w/2) {73 if(stack[i].x > width/2) { 65 74 stack[i].c.x = stack[i].x + rdf; 75 if(stack[i].c.visible == false && overlaps(i) == false) { 76 if(stack[i+1].x > stack[i].w+stack[i].x) { 77 rdf -= stack[i].w; 78 } else { 79 rdf -= stack[i+1].x - stack[i].x; 80 } 81 } 66 82 } else { 67 stack[i].c.x = stack[i].x+ldf; 83 stack[i].c.x = stack[i].x-ldf; 84 if(stack[i].c.visible == false && overlaps(i) == false) { 85 if(stack[i+1].x > stack[i].w+stack[i].x) { 86 ldf += stack[i].w; 87 } else { 88 ldf += stack[i+1].x - stack[i].x; 89 } 90 } 68 91 } 69 92 if(stack[i].w > width/3) { 70 93 stack[i].c.width = stack[i].w+rdf+ldf; 94 } 95 } 96 // if gaps were closed, move all rightside stuff to fill the width. 97 var dif = latest-width-rdf; 98 if(dif>0) { 99 for(var j=0; j<stack.length; j++) { 100 if(stack[j].x > width/2) { 101 stack[j].c.x += dif; 102 } 103 if(stack[j].w>width/3 && stack[j].n!='back') { 104 stack[j].c.width += dif; 105 } 71 106 } 72 107 } -
trunk/as3/com/jeroenwijering/views/ControlbarView.as
r5 r6 62 62 63 63 64 /** Handle clicks from all buttons **/64 /** Handle clicks from all buttons. **/ 65 65 private function clickHandler(evt:MouseEvent) { 66 66 view.sendEvent(BUTTONS[evt.target.name]); 67 }; 68 69 70 /** Fix the timeline display. **/ 71 private function fixTime() { 72 var scp = bar.timeSlider.scaleX; 73 bar.timeSlider.scaleX = 1; 74 bar.timeSlider.icon.x = Math.round(scp*bar.timeSlider.icon.x); 75 bar.timeSlider.mark.x = Math.round(scp*bar.timeSlider.mark.x); 76 bar.timeSlider.mark.width = Math.round(scp*bar.timeSlider.mark.width); 77 bar.timeSlider.rail.width = Math.round(scp*bar.timeSlider.rail.width); 67 78 }; 68 79 … … 80 91 bar.linkButton.visible = false; 81 92 } 93 stacker.rearrange(); 82 94 }; 83 95 … … 170 182 bar.normalscreenButton.visible = true; 171 183 } else { 172 bar.fullscreenButton.visible = false;173 bar.normalscreenButton.visible = true;184 bar.fullscreenButton.visible = true; 185 bar.normalscreenButton.visible = false; 174 186 } 175 187 stacker.rearrange(wid); 188 fixTime(); 176 189 }; 177 190 … … 205 218 switch(evt.data.newstate) { 206 219 case ModelStates.PLAYING: 207 if(view.config['controlbar'] == 'over' ) {220 if(view.config['controlbar'] == 'over' || bar.stage.displayState == 'fullScreen') { 208 221 hiding = setTimeout(moveTimeout,1000); 209 222 view.skin.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler); … … 214 227 break; 215 228 default: 216 if(view.config['controlbar'] == 'over' ) {229 if(view.config['controlbar'] == 'over' || bar.stage.displayState == 'fullScreen') { 217 230 clearTimeout(hiding); 218 231 Animations.fade(bar,1); … … 229 242 private function timeHandler(evt:ModelEvent) { 230 243 var dur = evt.data.duration; 231 bar.elapsedText. field.text = Strings.digits(evt.data.position);232 bar.totalText. field.text = Strings.digits(evt.data.duration)244 bar.elapsedText.text = Strings.digits(evt.data.position); 245 bar.totalText.text = Strings.digits(evt.data.duration) 233 246 var pct = evt.data.position/evt.data.duration; 234 var xps = Math. floor(pct*bar.timeSlider.rail.width);247 var xps = Math.round(pct*bar.timeSlider.rail.width); 235 248 if (dur <= 0) { 236 249 bar.timeSlider.icon.visible = false; -
trunk/as3/com/jeroenwijering/views/PlaylistView.as
r5 r6 94 94 buttons[i].s.rearrange(wid); 95 95 } 96 if(clr && proportion < 1) { 97 clip.back.height = buttons.length*buttonheight; 98 } 96 99 }; 97 100 … … 177 180 clip.x = clip.y = 0; 178 181 clip.back.width = evt.data.width; 179 if(proportion > 1 ) {182 if(proportion > 1 || buttons == null) { 180 183 clip.back.height = evt.data.height; 181 } else if(buttons) {184 } else { 182 185 clip.back.height = buttons.length*buttonheight; 183 186 } … … 227 230 } else if(itm == 'duration') { 228 231 if(view.playlist[idx][itm] > 0) { 229 buttons[idx].c[itm]. field.text = Strings.digits(view.playlist[idx][itm]);232 buttons[idx].c[itm].text = Strings.digits(view.playlist[idx][itm]); 230 233 } 231 234 } else { 232 buttons[idx].c[itm]. field.text = view.playlist[idx][itm];235 buttons[idx].c[itm].text = view.playlist[idx][itm]; 233 236 } 234 237 }
Note: See TracChangeset
for help on using the changeset viewer.
