| 1 | /** |
|---|
| 2 | * Display a controlbar with transport buttons and sliders. |
|---|
| 3 | **/ |
|---|
| 4 | package com.jeroenwijering.plugins { |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | import com.jeroenwijering.events.*; |
|---|
| 8 | import com.jeroenwijering.utils.*; |
|---|
| 9 | |
|---|
| 10 | import flash.accessibility.*; |
|---|
| 11 | import flash.display.*; |
|---|
| 12 | import flash.events.MouseEvent; |
|---|
| 13 | import flash.geom.ColorTransform; |
|---|
| 14 | import flash.geom.Rectangle; |
|---|
| 15 | import flash.net.URLRequest; |
|---|
| 16 | import flash.ui.Mouse; |
|---|
| 17 | import flash.utils.clearTimeout; |
|---|
| 18 | import flash.utils.setTimeout; |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | public class Controlbar implements PluginInterface { |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | /** List with configuration settings. **/ |
|---|
| 25 | public var config:Object = {}; |
|---|
| 26 | /** Reference to the controlbar clip. **/ |
|---|
| 27 | public var clip:MovieClip; |
|---|
| 28 | /** Reference to the view. **/ |
|---|
| 29 | private var view:AbstractView; |
|---|
| 30 | /** A list with all controls. **/ |
|---|
| 31 | private var stacker:Stacker; |
|---|
| 32 | /** Timeout for hiding the clip. **/ |
|---|
| 33 | private var hiding:Number; |
|---|
| 34 | /** When scrubbing, icon shouldn't be set. **/ |
|---|
| 35 | private var scrubber:MovieClip; |
|---|
| 36 | /** Color object for frontcolor. **/ |
|---|
| 37 | private var front:ColorTransform; |
|---|
| 38 | /** Color object for lightcolor. **/ |
|---|
| 39 | private var light:ColorTransform; |
|---|
| 40 | /** The actions for all controlbar buttons. **/ |
|---|
| 41 | private var BUTTONS = { |
|---|
| 42 | playButton:'PLAY', |
|---|
| 43 | pauseButton:'PLAY', |
|---|
| 44 | stopButton:'STOP', |
|---|
| 45 | prevButton:'PREV', |
|---|
| 46 | nextButton:'NEXT', |
|---|
| 47 | linkButton:'LINK', |
|---|
| 48 | fullscreenButton:'FULLSCREEN', |
|---|
| 49 | normalscreenButton:'FULLSCREEN', |
|---|
| 50 | muteButton:'MUTE', |
|---|
| 51 | unmuteButton:'MUTE' |
|---|
| 52 | }; |
|---|
| 53 | /** The actions for all sliders **/ |
|---|
| 54 | private var SLIDERS = { |
|---|
| 55 | timeSlider:'SEEK', |
|---|
| 56 | volumeSlider:'VOLUME' |
|---|
| 57 | } |
|---|
| 58 | /** The button to clone for all custom buttons. **/ |
|---|
| 59 | private var clonee:MovieClip; |
|---|
| 60 | /** Saving the block state of the controlbar. **/ |
|---|
| 61 | private var blocking:Boolean; |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | /** Constructor. **/ |
|---|
| 65 | public function Controlbar():void {}; |
|---|
| 66 | |
|---|
| 67 | /** |
|---|
| 68 | * Add a new button to the controlclip. |
|---|
| 69 | * |
|---|
| 70 | * @param icn A graphic to show as icon |
|---|
| 71 | * @param nam Name of the button |
|---|
| 72 | * @param hdl The function to call when clicking the button. |
|---|
| 73 | **/ |
|---|
| 74 | public function addButton(icn:DisplayObject,nam:String,hdl:Function):void { |
|---|
| 75 | if(clip['linkButton'].back) { |
|---|
| 76 | var btn = Draw.clone(clip['linkButton']); |
|---|
| 77 | btn.name = nam+'Button'; |
|---|
| 78 | btn.visible = true; |
|---|
| 79 | btn.tabEnabled = true; |
|---|
| 80 | btn.tabIndex = 6; |
|---|
| 81 | var acs:AccessibilityProperties = new AccessibilityProperties(); |
|---|
| 82 | acs.name = nam+'Button'; |
|---|
| 83 | btn.accessibilityProperties = acs; |
|---|
| 84 | clip.addChild(btn); |
|---|
| 85 | var off:Number = Math.round((btn.height-icn.height)/2); |
|---|
| 86 | Draw.clear(btn.icon); |
|---|
| 87 | btn.icon.addChild(icn); |
|---|
| 88 | icn.x = icn.y = 0; |
|---|
| 89 | btn.icon.x = btn.icon.y = off; |
|---|
| 90 | btn.back.width = icn.width+2*off; |
|---|
| 91 | btn.buttonMode = true; |
|---|
| 92 | btn.mouseChildren = false; |
|---|
| 93 | btn.addEventListener(MouseEvent.CLICK,hdl); |
|---|
| 94 | if(front) { |
|---|
| 95 | btn.icon.transform.colorTransform = front; |
|---|
| 96 | btn.addEventListener(MouseEvent.MOUSE_OVER,overHandler); |
|---|
| 97 | btn.addEventListener(MouseEvent.MOUSE_OUT,outHandler); |
|---|
| 98 | } |
|---|
| 99 | stacker.insert(btn,clip['linkButton']); |
|---|
| 100 | } |
|---|
| 101 | }; |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | /** Hide the controlbar **/ |
|---|
| 105 | public function block(stt:Boolean):void { |
|---|
| 106 | blocking = stt; |
|---|
| 107 | timeHandler(); |
|---|
| 108 | }; |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | /** Handle clicks from all buttons. **/ |
|---|
| 112 | private function clickHandler(evt:MouseEvent):void { |
|---|
| 113 | var act:String = BUTTONS[evt.target.name]; |
|---|
| 114 | if(blocking != true || act == "FULLSCREEN" || act == "MUTE") { |
|---|
| 115 | view.sendEvent(act); |
|---|
| 116 | } |
|---|
| 117 | }; |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | /** Handle mouse presses on sliders. **/ |
|---|
| 121 | private function downHandler(evt:MouseEvent):void { |
|---|
| 122 | scrubber = MovieClip(evt.target); |
|---|
| 123 | if(blocking != true || scrubber.name == 'volumeSlider') { |
|---|
| 124 | var rct:Rectangle = new Rectangle(scrubber.rail.x,scrubber.icon.y,scrubber.rail.width-scrubber.icon.width,0); |
|---|
| 125 | scrubber.icon.startDrag(true,rct); |
|---|
| 126 | clip.stage.addEventListener(MouseEvent.MOUSE_UP,upHandler); |
|---|
| 127 | } else { |
|---|
| 128 | scrubber = undefined; |
|---|
| 129 | } |
|---|
| 130 | }; |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | /** Fix the timeline display. **/ |
|---|
| 134 | private function fixTime():void { |
|---|
| 135 | try { |
|---|
| 136 | var scp:Number = clip.timeSlider.scaleX; |
|---|
| 137 | clip.timeSlider.scaleX = 1; |
|---|
| 138 | clip.timeSlider.icon.x = scp*clip.timeSlider.icon.x; |
|---|
| 139 | clip.timeSlider.mark.x = scp*clip.timeSlider.mark.x; |
|---|
| 140 | clip.timeSlider.mark.width = scp*clip.timeSlider.mark.width; |
|---|
| 141 | clip.timeSlider.rail.width = scp*clip.timeSlider.rail.width; |
|---|
| 142 | clip.timeSlider.done.x = scp*clip.timeSlider.done.x; |
|---|
| 143 | clip.timeSlider.done.width = scp*clip.timeSlider.done.width; |
|---|
| 144 | } catch (err:Error) {} |
|---|
| 145 | }; |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | /** Initialize from view. **/ |
|---|
| 149 | public function initializePlugin(vie:AbstractView):void { |
|---|
| 150 | view = vie; |
|---|
| 151 | view.addControllerListener(ControllerEvent.RESIZE,resizeHandler); |
|---|
| 152 | view.addModelListener(ModelEvent.LOADED,loadedHandler); |
|---|
| 153 | view.addModelListener(ModelEvent.STATE,stateHandler); |
|---|
| 154 | view.addModelListener(ModelEvent.TIME,timeHandler); |
|---|
| 155 | view.addControllerListener(ControllerEvent.PLAYLIST,itemHandler); |
|---|
| 156 | view.addControllerListener(ControllerEvent.ITEM,itemHandler); |
|---|
| 157 | view.addControllerListener(ControllerEvent.MUTE,muteHandler); |
|---|
| 158 | view.addControllerListener(ControllerEvent.VOLUME,volumeHandler); |
|---|
| 159 | stacker = new Stacker(clip); |
|---|
| 160 | setButtons(); |
|---|
| 161 | setColors(); |
|---|
| 162 | itemHandler(); |
|---|
| 163 | loadedHandler(); |
|---|
| 164 | muteHandler(); |
|---|
| 165 | stateHandler(); |
|---|
| 166 | timeHandler(); |
|---|
| 167 | volumeHandler(); |
|---|
| 168 | }; |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | /** Handle a change in the current item **/ |
|---|
| 172 | private function itemHandler(evt:ControllerEvent=null):void { |
|---|
| 173 | try { |
|---|
| 174 | if(view.playlist && view.playlist.length > 1) { |
|---|
| 175 | clip.prevButton.visible = clip.nextButton.visible = true; |
|---|
| 176 | } else { |
|---|
| 177 | clip.prevButton.visible = clip.nextButton.visible = false; |
|---|
| 178 | } |
|---|
| 179 | } catch (err:Error) {} |
|---|
| 180 | try { |
|---|
| 181 | if(view.playlist && view.playlist[view.config['item']]['link']) { |
|---|
| 182 | clip.linkButton.visible = true; |
|---|
| 183 | } else { |
|---|
| 184 | clip.linkButton.visible = false; |
|---|
| 185 | } |
|---|
| 186 | } catch (err:Error) {} |
|---|
| 187 | timeHandler(); |
|---|
| 188 | stacker.rearrange(); |
|---|
| 189 | fixTime(); |
|---|
| 190 | loadedHandler(new ModelEvent(ModelEvent.LOADED,{loaded:0,total:0})) |
|---|
| 191 | }; |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | /** Process bytesloaded updates given by the model. **/ |
|---|
| 195 | private function loadedHandler(evt:ModelEvent=null):void { |
|---|
| 196 | var pc1:Number = 0; |
|---|
| 197 | if(evt && evt.data.total > 0) { |
|---|
| 198 | pc1 = evt.data.loaded/evt.data.total; |
|---|
| 199 | } |
|---|
| 200 | var pc2:Number = 0; |
|---|
| 201 | if(evt && evt.data.offset) { |
|---|
| 202 | pc2 = evt.data.offset/evt.data.total; |
|---|
| 203 | } |
|---|
| 204 | try { |
|---|
| 205 | var wid:Number = clip.timeSlider.rail.width; |
|---|
| 206 | clip.timeSlider.mark.x = pc2*wid; |
|---|
| 207 | clip.timeSlider.mark.width = pc1*wid; |
|---|
| 208 | var icw:Number = clip.timeSlider.icon.x + clip.timeSlider.icon.width; |
|---|
| 209 | } catch (err:Error) {} |
|---|
| 210 | }; |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | /** Show above controlbar on mousemove. **/ |
|---|
| 214 | private function moveHandler(evt:MouseEvent=null):void { |
|---|
| 215 | if(clip.alpha == 0) { Animations.fade(clip,1); } |
|---|
| 216 | clearTimeout(hiding); |
|---|
| 217 | hiding = setTimeout(moveTimeout,2000); |
|---|
| 218 | Mouse.show(); |
|---|
| 219 | }; |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | /** Hide above controlbar again when move has timed out. **/ |
|---|
| 223 | private function moveTimeout():void { |
|---|
| 224 | Animations.fade(clip,0); |
|---|
| 225 | Mouse.hide(); |
|---|
| 226 | }; |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | /** Show a mute icon if playing. **/ |
|---|
| 230 | private function muteHandler(evt:ControllerEvent=null):void { |
|---|
| 231 | if(view.config['mute'] == true) { |
|---|
| 232 | try { |
|---|
| 233 | clip.muteButton.visible = false; |
|---|
| 234 | clip.unmuteButton.visible = true; |
|---|
| 235 | } catch (err:Error) {} |
|---|
| 236 | try { |
|---|
| 237 | clip.volumeSlider.mark.visible = false; |
|---|
| 238 | clip.volumeSlider.icon.x = clip.volumeSlider.rail.x; |
|---|
| 239 | } catch (err:Error) {} |
|---|
| 240 | } else { |
|---|
| 241 | try { |
|---|
| 242 | clip.muteButton.visible = true; |
|---|
| 243 | clip.unmuteButton.visible = false; |
|---|
| 244 | } catch (err:Error) {} |
|---|
| 245 | try { |
|---|
| 246 | clip.volumeSlider.mark.visible = true; |
|---|
| 247 | volumeHandler(); |
|---|
| 248 | } catch (err:Error) {} |
|---|
| 249 | } |
|---|
| 250 | }; |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | /** Handle mouseouts from all buttons **/ |
|---|
| 254 | private function outHandler(evt:MouseEvent):void { |
|---|
| 255 | if(front && evt.target['icon']) { |
|---|
| 256 | evt.target['icon'].transform.colorTransform = front; |
|---|
| 257 | } else { |
|---|
| 258 | evt.target.gotoAndPlay('out'); |
|---|
| 259 | } |
|---|
| 260 | }; |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | /** Handle clicks from all buttons **/ |
|---|
| 264 | private function overHandler(evt:MouseEvent):void { |
|---|
| 265 | if(front && evt.target['icon']) { |
|---|
| 266 | evt.target['icon'].transform.colorTransform = light; |
|---|
| 267 | } else { |
|---|
| 268 | evt.target.gotoAndPlay('over'); |
|---|
| 269 | } |
|---|
| 270 | }; |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | /** Process resizing requests **/ |
|---|
| 274 | private function resizeHandler(evt:ControllerEvent=null):void { |
|---|
| 275 | var wid:Number = config['width']; |
|---|
| 276 | clip.x = config['x']; |
|---|
| 277 | clip.y = config['y']; |
|---|
| 278 | clip.visible = config['visible']; |
|---|
| 279 | if(config['position'] == 'over' || view.config['fullscreen'] == true) { |
|---|
| 280 | clip.x = config['x'] + config['margin']; |
|---|
| 281 | clip.y = config['y'] + config['height'] - config['margin'] - config['size']; |
|---|
| 282 | wid = config['width'] - 2*config['margin']; |
|---|
| 283 | clip.back.alpha = 0.75; |
|---|
| 284 | } else if(config['position'] != 'none') { |
|---|
| 285 | clip.back.alpha = 1; |
|---|
| 286 | } |
|---|
| 287 | try { |
|---|
| 288 | clip.fullscreenButton.visible = false; |
|---|
| 289 | clip.normalscreenButton.visible = false; |
|---|
| 290 | if(clip.stage['displayState'] && view.config['height'] > 40) { |
|---|
| 291 | if(view.config['fullscreen']) { |
|---|
| 292 | clip.fullscreenButton.visible = false; |
|---|
| 293 | clip.normalscreenButton.visible = true; |
|---|
| 294 | } else { |
|---|
| 295 | clip.fullscreenButton.visible = true; |
|---|
| 296 | clip.normalscreenButton.visible = false; |
|---|
| 297 | } |
|---|
| 298 | } |
|---|
| 299 | } catch (err:Error) {} |
|---|
| 300 | stacker.rearrange(wid); |
|---|
| 301 | stateHandler(); |
|---|
| 302 | fixTime(); |
|---|
| 303 | Mouse.show(); |
|---|
| 304 | }; |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | /** Clickhandler for all buttons. **/ |
|---|
| 308 | private function setButtons():void { |
|---|
| 309 | for(var btn:String in BUTTONS) { |
|---|
| 310 | if(clip[btn]) { |
|---|
| 311 | clip[btn].mouseChildren = false; |
|---|
| 312 | clip[btn].buttonMode = true; |
|---|
| 313 | clip[btn].addEventListener(MouseEvent.CLICK, clickHandler); |
|---|
| 314 | clip[btn].addEventListener(MouseEvent.MOUSE_OVER, overHandler); |
|---|
| 315 | clip[btn].addEventListener(MouseEvent.MOUSE_OUT, outHandler); |
|---|
| 316 | } |
|---|
| 317 | } |
|---|
| 318 | for(var sld:String in SLIDERS) { |
|---|
| 319 | if(clip[sld]) { |
|---|
| 320 | clip[sld].mouseChildren = false; |
|---|
| 321 | clip[sld].buttonMode = true; |
|---|
| 322 | clip[sld].addEventListener(MouseEvent.MOUSE_DOWN, downHandler); |
|---|
| 323 | clip[sld].addEventListener(MouseEvent.MOUSE_OVER, overHandler); |
|---|
| 324 | clip[sld].addEventListener(MouseEvent.MOUSE_OUT, outHandler); |
|---|
| 325 | } |
|---|
| 326 | } |
|---|
| 327 | }; |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | /** Init the colors. **/ |
|---|
| 331 | private function setColors():void { |
|---|
| 332 | if(view.config['backcolor'] && clip['playButton'].icon) { |
|---|
| 333 | var clr:ColorTransform = new ColorTransform(); |
|---|
| 334 | clr.color = uint('0x'+view.config['backcolor'].substr(-6)); |
|---|
| 335 | clip.back.transform.colorTransform = clr; |
|---|
| 336 | } |
|---|
| 337 | if(view.config['frontcolor']) { |
|---|
| 338 | try { |
|---|
| 339 | front = new ColorTransform(); |
|---|
| 340 | front.color = uint('0x'+view.config['frontcolor'].substr(-6)); |
|---|
| 341 | for(var btn:String in BUTTONS) { |
|---|
| 342 | if(clip[btn]) { |
|---|
| 343 | clip[btn]['icon'].transform.colorTransform = front; |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | for(var sld:String in SLIDERS) { |
|---|
| 347 | if(clip[sld]) { |
|---|
| 348 | clip[sld]['icon'].transform.colorTransform = front; |
|---|
| 349 | clip[sld]['mark'].transform.colorTransform = front; |
|---|
| 350 | clip[sld]['rail'].transform.colorTransform = front; |
|---|
| 351 | } |
|---|
| 352 | } |
|---|
| 353 | clip.elapsedText.textColor = front.color; |
|---|
| 354 | clip.totalText.textColor = front.color; |
|---|
| 355 | } catch (err:Error) {} |
|---|
| 356 | } |
|---|
| 357 | if(view.config['lightcolor']) { |
|---|
| 358 | light = new ColorTransform(); |
|---|
| 359 | light.color = uint('0x'+view.config['lightcolor'].substr(-6)); |
|---|
| 360 | } else { |
|---|
| 361 | light = front; |
|---|
| 362 | } |
|---|
| 363 | if(light) { |
|---|
| 364 | try { |
|---|
| 365 | clip['timeSlider']['done'].transform.colorTransform = light; |
|---|
| 366 | clip['volumeSlider']['mark'].transform.colorTransform = light; |
|---|
| 367 | } catch (err:Error) {} |
|---|
| 368 | } |
|---|
| 369 | }; |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | /** Process state changes **/ |
|---|
| 373 | private function stateHandler(evt:ModelEvent=undefined):void { |
|---|
| 374 | clearTimeout(hiding); |
|---|
| 375 | view.skin.removeEventListener(MouseEvent.MOUSE_MOVE,moveHandler); |
|---|
| 376 | try { |
|---|
| 377 | var dps:String = clip.stage['displayState']; |
|---|
| 378 | } catch (err:Error) {} |
|---|
| 379 | switch(view.config['state']) { |
|---|
| 380 | case ModelStates.PLAYING: |
|---|
| 381 | case ModelStates.BUFFERING: |
|---|
| 382 | try { |
|---|
| 383 | clip.playButton.visible = false; |
|---|
| 384 | clip.pauseButton.visible = true; |
|---|
| 385 | } catch (err:Error) {} |
|---|
| 386 | if(config['position'] == 'over' || dps == 'fullScreen') { |
|---|
| 387 | hiding = setTimeout(moveTimeout,2000); |
|---|
| 388 | view.skin.addEventListener(MouseEvent.MOUSE_MOVE,moveHandler); |
|---|
| 389 | } else { |
|---|
| 390 | Animations.fade(clip,1); |
|---|
| 391 | } |
|---|
| 392 | break; |
|---|
| 393 | default: |
|---|
| 394 | try { |
|---|
| 395 | clip.playButton.visible = true; |
|---|
| 396 | clip.pauseButton.visible = false; |
|---|
| 397 | } catch (err:Error) {} |
|---|
| 398 | if(config['position'] == 'over' || dps == 'fullScreen') { |
|---|
| 399 | Mouse.show(); |
|---|
| 400 | Animations.fade(clip,1); |
|---|
| 401 | } |
|---|
| 402 | } |
|---|
| 403 | }; |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | /** Process time updates given by the model. **/ |
|---|
| 407 | private function timeHandler(evt:ModelEvent=null):void { |
|---|
| 408 | var dur:Number = 0; |
|---|
| 409 | var pos:Number = 0; |
|---|
| 410 | if(evt) { |
|---|
| 411 | dur = evt.data.duration; |
|---|
| 412 | pos = evt.data.position; |
|---|
| 413 | } else if(view.playlist) { |
|---|
| 414 | dur = view.playlist[view.config['item']]['duration']; |
|---|
| 415 | pos = 0; |
|---|
| 416 | } |
|---|
| 417 | var pct:Number = pos/dur; |
|---|
| 418 | if(isNaN(pct)) { pct = 1; } |
|---|
| 419 | try { |
|---|
| 420 | clip.elapsedText.text = Strings.digits(pos); |
|---|
| 421 | clip.totalText.text = Strings.digits(dur); |
|---|
| 422 | } catch (err:Error) {} |
|---|
| 423 | try { |
|---|
| 424 | var tsl:MovieClip = clip.timeSlider; |
|---|
| 425 | var xps:Number = Math.round(pct*(tsl.rail.width-tsl.icon.width)); |
|---|
| 426 | if (dur > 0) { |
|---|
| 427 | clip.timeSlider.icon.visible = true; |
|---|
| 428 | clip.timeSlider.mark.visible = true; |
|---|
| 429 | if(!scrubber) { |
|---|
| 430 | clip.timeSlider.icon.x = xps; |
|---|
| 431 | clip.timeSlider.done.width = xps; |
|---|
| 432 | } |
|---|
| 433 | clip.timeSlider.done.visible = true; |
|---|
| 434 | } else { |
|---|
| 435 | clip.timeSlider.icon.visible = false; |
|---|
| 436 | clip.timeSlider.mark.visible = false; |
|---|
| 437 | clip.timeSlider.done.visible = false; |
|---|
| 438 | } |
|---|
| 439 | } catch (err:Error) {} |
|---|
| 440 | }; |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | /** Handle mouse releases on sliders. **/ |
|---|
| 444 | private function upHandler(evt:MouseEvent):void { |
|---|
| 445 | var mpl:Number = 0; |
|---|
| 446 | clip.stage.removeEventListener(MouseEvent.MOUSE_UP,upHandler); |
|---|
| 447 | scrubber.icon.stopDrag(); |
|---|
| 448 | if(scrubber.name == 'timeSlider' && view.playlist) { |
|---|
| 449 | mpl = view.playlist[view.config['item']]['duration']; |
|---|
| 450 | } else if(scrubber.name == 'volumeSlider') { |
|---|
| 451 | mpl = 100; |
|---|
| 452 | } |
|---|
| 453 | var pct:Number = (scrubber.icon.x-scrubber.rail.x) / (scrubber.rail.width-scrubber.icon.width) * mpl; |
|---|
| 454 | view.sendEvent(SLIDERS[scrubber.name],Math.round(pct)); |
|---|
| 455 | scrubber = undefined; |
|---|
| 456 | }; |
|---|
| 457 | |
|---|
| 458 | |
|---|
| 459 | /** Reflect the new volume in the controlbar **/ |
|---|
| 460 | private function volumeHandler(evt:ControllerEvent=null):void { |
|---|
| 461 | try { |
|---|
| 462 | var vsl:MovieClip = clip.volumeSlider; |
|---|
| 463 | vsl.mark.width = view.config['volume']*(vsl.rail.width-vsl.icon.width/2)/100; |
|---|
| 464 | vsl.icon.x = vsl.mark.x + view.config['volume']*(vsl.rail.width-vsl.icon.width)/100; |
|---|
| 465 | } catch (err:Error) {} |
|---|
| 466 | }; |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | }; |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | } |
|---|