- Timestamp:
- 08/25/10 19:40:11 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fl5/src/com/longtailvideo/jwplayer/view/components/ControlbarComponent.as
r1059 r1238 11 11 import com.longtailvideo.jwplayer.utils.Animations; 12 12 import com.longtailvideo.jwplayer.utils.Logger; 13 import com.longtailvideo.jwplayer.utils.RootReference; 13 14 import com.longtailvideo.jwplayer.utils.Strings; 14 15 import com.longtailvideo.jwplayer.view.interfaces.IControlbarComponent; … … 17 18 import flash.display.MovieClip; 18 19 import flash.display.Sprite; 20 import flash.events.Event; 19 21 import flash.events.MouseEvent; 20 22 import flash.geom.ColorTransform; … … 103 105 protected var _bgColorSheet:Sprite; 104 106 107 protected var _fullscreen:Boolean = false; 108 105 109 protected var controlbarConfig:PluginConfig; 106 110 protected var animations:Animations; … … 109 113 public function ControlbarComponent(player:IPlayer) { 110 114 super(player, "controlbar"); 115 controlbarConfig = _player.config.pluginConfig(_name); 116 animations = new Animations(this); 117 if (controlbarConfig['position'] == "over" && hideOnIdle) { 118 alpha = 0; 119 } 120 111 121 _layoutManager = new ControlbarLayoutManager(this); 112 122 _dividers = []; … … 118 128 setTime(0, 0); 119 129 updateVolumeSlider(); 120 controlbarConfig = _player.config.pluginConfig(_name);121 animations = new Animations(this);122 130 } 123 131 … … 133 141 player.addEventListener(PlayerEvent.JWPLAYER_LOCKED, lockHandler); 134 142 player.addEventListener(PlayerEvent.JWPLAYER_UNLOCKED, lockHandler); 143 RootReference.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeftStage); 144 RootReference.stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler); 135 145 } 136 146 … … 153 163 } 154 164 165 private function get fadeOnTimeout():Boolean { 166 return controlbarConfig['position'] == 'over' || (_player.config.fullscreen && controlbarConfig['position'] != 'none'); 167 } 168 169 private function get hideOnIdle():Boolean { 170 return String(controlbarConfig['idlehide']) == "true"; 171 } 155 172 156 173 private function startFader():void { 157 if ( controlbarConfig['position'] == 'over' || (_player.config.fullscreen && controlbarConfig['position'] != 'none')) {174 if (fadeOnTimeout) { 158 175 if (!isNaN(hiding)) { 159 176 clearTimeout(hiding); 160 177 } 161 178 hiding = setTimeout(moveTimeout, 2000); 162 _player.controls.display.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);163 addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);164 179 } 165 180 } 166 181 167 182 private function stopFader():void { 183 if (alpha == 0) { 184 animations.fade(1, 0.5); 185 } 168 186 if (!isNaN(hiding)) { 169 187 clearTimeout(hiding); 170 try { 171 _player.controls.display.removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler); 172 removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler); 173 } catch (e:Error) {} 174 } 175 Mouse.show(); 176 animations.fade(1, 0.5); 177 } 178 179 /** Show above controlbar on mousemove. **/ 188 Mouse.show(); 189 } 190 } 191 192 /** Show above controlbar on mousemove and restart the countdown. **/ 180 193 private function moveHandler(evt:MouseEvent=null):void { 181 194 if (alpha == 0) { 182 animations.fade(1, 0.5); 183 } 184 clearTimeout(hiding); 185 hiding = setTimeout(moveTimeout, 2000); 186 Mouse.show(); 187 } 188 195 stopFader(); 196 startFader(); 197 } 198 } 189 199 190 200 /** Hide above controlbar again when move has timed out. **/ 191 private function moveTimeout( ):void {201 private function moveTimeout(evt:Event=null):void { 192 202 animations.fade(0, 0.5); 193 203 Mouse.hide(); 204 } 205 206 /** If the mouse leaves the stage, hide the controlbar if position is 'over' **/ 207 private function mouseLeftStage(evt:Event=null):void { 208 if (fadeOnTimeout) { 209 if (_player.state == PlayerState.BUFFERING || _player.state == PlayerState.PLAYING || hideOnIdle) 210 animations.fade(0); 211 } 194 212 } 195 213 … … 202 220 case PlayerState.PAUSED: 203 221 case PlayerState.IDLE: 204 stopFader(); 222 if (hideOnIdle) { 223 mouseLeftStage(); 224 } else { 225 stopFader(); 226 } 205 227 break; 206 228 } … … 656 678 _bgColorSheet.height = background.height; 657 679 658 stopFader(); 680 if (_fullscreen && !_player.config.fullscreen) { 681 stopFader(); 682 } 683 _fullscreen = _player.config.fullscreen; 659 684 stateHandler(); 660 685 redraw();
Note: See TracChangeset
for help on using the changeset viewer.
