| 1 | package com.longtailvideo.jwplayer.view { |
|---|
| 2 | import com.longtailvideo.jwplayer.events.GlobalEventDispatcher; |
|---|
| 3 | import com.longtailvideo.jwplayer.events.MediaEvent; |
|---|
| 4 | import com.longtailvideo.jwplayer.events.PlayerEvent; |
|---|
| 5 | import com.longtailvideo.jwplayer.events.PlayerStateEvent; |
|---|
| 6 | import com.longtailvideo.jwplayer.events.PlaylistEvent; |
|---|
| 7 | import com.longtailvideo.jwplayer.events.ViewEvent; |
|---|
| 8 | import com.longtailvideo.jwplayer.model.Model; |
|---|
| 9 | import com.longtailvideo.jwplayer.player.IPlayer; |
|---|
| 10 | import com.longtailvideo.jwplayer.player.PlayerState; |
|---|
| 11 | import com.longtailvideo.jwplayer.player.PlayerV4Emulation; |
|---|
| 12 | import com.longtailvideo.jwplayer.plugins.IPlugin; |
|---|
| 13 | import com.longtailvideo.jwplayer.plugins.PluginConfig; |
|---|
| 14 | import com.longtailvideo.jwplayer.utils.AssetLoader; |
|---|
| 15 | import com.longtailvideo.jwplayer.utils.Draw; |
|---|
| 16 | import com.longtailvideo.jwplayer.utils.Logger; |
|---|
| 17 | import com.longtailvideo.jwplayer.utils.RootReference; |
|---|
| 18 | import com.longtailvideo.jwplayer.utils.Stretcher; |
|---|
| 19 | import com.longtailvideo.jwplayer.view.interfaces.IControlbarComponent; |
|---|
| 20 | import com.longtailvideo.jwplayer.view.interfaces.IDisplayComponent; |
|---|
| 21 | import com.longtailvideo.jwplayer.view.interfaces.IDockComponent; |
|---|
| 22 | import com.longtailvideo.jwplayer.view.interfaces.IPlayerComponent; |
|---|
| 23 | import com.longtailvideo.jwplayer.view.interfaces.IPlaylistComponent; |
|---|
| 24 | import com.longtailvideo.jwplayer.view.interfaces.ISkin; |
|---|
| 25 | |
|---|
| 26 | import flash.display.Bitmap; |
|---|
| 27 | import flash.display.DisplayObject; |
|---|
| 28 | import flash.display.MovieClip; |
|---|
| 29 | import flash.display.Sprite; |
|---|
| 30 | import flash.display.Stage; |
|---|
| 31 | import flash.display.StageAlign; |
|---|
| 32 | import flash.display.StageDisplayState; |
|---|
| 33 | import flash.display.StageScaleMode; |
|---|
| 34 | import flash.events.ErrorEvent; |
|---|
| 35 | import flash.events.Event; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | public class View extends GlobalEventDispatcher { |
|---|
| 39 | protected var _player:IPlayer; |
|---|
| 40 | protected var _model:Model; |
|---|
| 41 | protected var _skin:ISkin; |
|---|
| 42 | protected var _components:IPlayerComponents; |
|---|
| 43 | protected var _fullscreen:Boolean = false; |
|---|
| 44 | protected var stage:Stage; |
|---|
| 45 | |
|---|
| 46 | protected var _root:MovieClip; |
|---|
| 47 | |
|---|
| 48 | protected var _backgroundLayer:MovieClip; |
|---|
| 49 | protected var _mediaLayer:MovieClip; |
|---|
| 50 | protected var _imageLayer:MovieClip; |
|---|
| 51 | protected var _componentsLayer:MovieClip; |
|---|
| 52 | protected var _logoLayer:MovieClip; |
|---|
| 53 | protected var _pluginsLayer:MovieClip; |
|---|
| 54 | protected var _plugins:Object; |
|---|
| 55 | |
|---|
| 56 | protected var _displayMasker:MovieClip; |
|---|
| 57 | |
|---|
| 58 | protected var _image:AssetLoader; |
|---|
| 59 | protected var _logo:Logo; |
|---|
| 60 | |
|---|
| 61 | protected var layoutManager:PlayerLayoutManager; |
|---|
| 62 | |
|---|
| 63 | [Embed(source="../../../../../assets/flash/loader/loader.swf")] |
|---|
| 64 | protected var LoadingScreen:Class; |
|---|
| 65 | |
|---|
| 66 | [Embed(source="../../../../../assets/flash/loader/error.swf")] |
|---|
| 67 | protected var ErrorScreen:Class; |
|---|
| 68 | |
|---|
| 69 | protected var loaderScreen:Sprite; |
|---|
| 70 | protected var loaderAnim:DisplayObject; |
|---|
| 71 | |
|---|
| 72 | protected var currentLayer:Number = 0; |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | public function View(player:IPlayer, model:Model) { |
|---|
| 76 | _player = player; |
|---|
| 77 | _model = model; |
|---|
| 78 | |
|---|
| 79 | RootReference.stage.scaleMode = StageScaleMode.NO_SCALE; |
|---|
| 80 | RootReference.stage.stage.align = StageAlign.TOP_LEFT; |
|---|
| 81 | |
|---|
| 82 | loaderScreen = new Sprite(); |
|---|
| 83 | loaderScreen.name = 'loaderScreen'; |
|---|
| 84 | |
|---|
| 85 | loaderAnim = new LoadingScreen() as DisplayObject; |
|---|
| 86 | loaderScreen.addChild(loaderAnim); |
|---|
| 87 | |
|---|
| 88 | RootReference.stage.addChildAt(loaderScreen, 0); |
|---|
| 89 | |
|---|
| 90 | if (RootReference.stage.stageWidth > 0) { |
|---|
| 91 | resizeStage(); |
|---|
| 92 | } else { |
|---|
| 93 | RootReference.stage.addEventListener(Event.RESIZE, resizeStage); |
|---|
| 94 | RootReference.stage.addEventListener(Event.ADDED_TO_STAGE, resizeStage); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | _root = new MovieClip(); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | protected function resizeStage(evt:Event=null):void { |
|---|
| 102 | RootReference.stage.removeEventListener(Event.RESIZE, resizeStage); |
|---|
| 103 | RootReference.stage.removeEventListener(Event.ADDED_TO_STAGE, resizeStage); |
|---|
| 104 | |
|---|
| 105 | loaderScreen.graphics.clear(); |
|---|
| 106 | loaderScreen.graphics.beginFill(0, 1); |
|---|
| 107 | loaderScreen.graphics.drawRect(0, 0, RootReference.stage.stageWidth, RootReference.stage.stageHeight); |
|---|
| 108 | loaderScreen.graphics.endFill(); |
|---|
| 109 | |
|---|
| 110 | loaderAnim.x = (RootReference.stage.stageWidth - loaderAnim.width) / 2; |
|---|
| 111 | loaderAnim.y = (RootReference.stage.stageHeight - loaderAnim.height) / 2; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | public function get skin():ISkin { |
|---|
| 116 | return _skin; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | public function set skin(skn:ISkin):void { |
|---|
| 121 | _skin = skn; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | public function setupView():void { |
|---|
| 126 | RootReference.stage.addChildAt(_root, 0); |
|---|
| 127 | _root.visible = false; |
|---|
| 128 | |
|---|
| 129 | setupLayers(); |
|---|
| 130 | setupComponents(); |
|---|
| 131 | |
|---|
| 132 | RootReference.stage.addEventListener(Event.FULLSCREEN, resizeHandler); |
|---|
| 133 | RootReference.stage.addEventListener(Event.RESIZE, resizeHandler); |
|---|
| 134 | |
|---|
| 135 | _model.addEventListener(MediaEvent.JWPLAYER_MEDIA_LOADED, mediaLoaded); |
|---|
| 136 | _model.playlist.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_ITEM, itemHandler); |
|---|
| 137 | //_model.playlist.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_LOADED, itemHandler); |
|---|
| 138 | _model.playlist.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_UPDATED, itemHandler); |
|---|
| 139 | _model.addEventListener(PlayerStateEvent.JWPLAYER_PLAYER_STATE, stateHandler); |
|---|
| 140 | |
|---|
| 141 | layoutManager = new PlayerLayoutManager(_player); |
|---|
| 142 | setupRightClick(); |
|---|
| 143 | |
|---|
| 144 | redraw(); |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | protected function setupRightClick():void { |
|---|
| 148 | var menu:RightclickMenu = new RightclickMenu(_player, _root); |
|---|
| 149 | menu.addGlobalListener(forward); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | public function completeView(isError:Boolean=false, errorMsg:String=""):void { |
|---|
| 153 | if (!isError) { |
|---|
| 154 | _root.visible = true; |
|---|
| 155 | RootReference.stage.removeChild(loaderScreen); |
|---|
| 156 | } else { |
|---|
| 157 | loaderScreen.removeChild(loaderAnim); |
|---|
| 158 | var errorScreen:DisplayObject = new ErrorScreen() as DisplayObject; |
|---|
| 159 | errorScreen.x = (loaderScreen.width - errorScreen.width) / 2; |
|---|
| 160 | errorScreen.y = (loaderScreen.height - errorScreen.height) / 2; |
|---|
| 161 | loaderScreen.addChild(errorScreen); |
|---|
| 162 | } |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | protected function setupLayers():void { |
|---|
| 167 | _backgroundLayer = setupLayer("background", currentLayer++); |
|---|
| 168 | setupBackground(); |
|---|
| 169 | |
|---|
| 170 | _mediaLayer = setupLayer("media", currentLayer++); |
|---|
| 171 | _mediaLayer.visible = false; |
|---|
| 172 | |
|---|
| 173 | _imageLayer = setupLayer("image", currentLayer++); |
|---|
| 174 | _image = new AssetLoader(); |
|---|
| 175 | _image.addEventListener(Event.COMPLETE, imageComplete); |
|---|
| 176 | _image.addEventListener(ErrorEvent.ERROR, imageError); |
|---|
| 177 | |
|---|
| 178 | setupLogo(); |
|---|
| 179 | |
|---|
| 180 | _componentsLayer = setupLayer("components", currentLayer++); |
|---|
| 181 | |
|---|
| 182 | _pluginsLayer = setupLayer("plugins", currentLayer++); |
|---|
| 183 | _plugins = {}; |
|---|
| 184 | |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | protected function setupLogo():void { |
|---|
| 188 | _logoLayer = setupLayer("logo", currentLayer++); |
|---|
| 189 | _logo = new Logo(_player); |
|---|
| 190 | _logoLayer.addChild(_logo); |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | protected function setupLayer(name:String, index:Number):MovieClip { |
|---|
| 195 | var layer:MovieClip = new MovieClip(); |
|---|
| 196 | _root.addChildAt(layer, index); |
|---|
| 197 | layer.name = name; |
|---|
| 198 | layer.x = 0; |
|---|
| 199 | layer.y = 0; |
|---|
| 200 | return layer; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | protected function setupBackground():void { |
|---|
| 205 | var background:MovieClip = new MovieClip(); |
|---|
| 206 | background.name = "background"; |
|---|
| 207 | _backgroundLayer.addChild(background); |
|---|
| 208 | background.graphics.beginFill(_player.config.screencolor ? _player.config.screencolor.color : 0x000000, 1); |
|---|
| 209 | background.graphics.drawRect(0, 0, 1, 1); |
|---|
| 210 | background.graphics.endFill(); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | protected function setupDisplayMask():void { |
|---|
| 215 | _displayMasker = new MovieClip(); |
|---|
| 216 | _displayMasker.graphics.beginFill(0x000000, 1); |
|---|
| 217 | _displayMasker.graphics.drawRect(0, 0, _player.config.width, _player.config.height); |
|---|
| 218 | _displayMasker.graphics.endFill(); |
|---|
| 219 | |
|---|
| 220 | _backgroundLayer.mask = _displayMasker; |
|---|
| 221 | _imageLayer.mask = _displayMasker; |
|---|
| 222 | _mediaLayer.mask = _displayMasker; |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | protected function setupComponents():void { |
|---|
| 227 | _components = new PlayerComponents(_player); |
|---|
| 228 | |
|---|
| 229 | setupComponent(_components.display, 0); |
|---|
| 230 | setupComponent(_components.playlist, 1); |
|---|
| 231 | setupComponent(_components.controlbar, 2); |
|---|
| 232 | setupComponent(_components.dock, 3); |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | protected function setupComponent(component:IPlayerComponent, index:Number):void { |
|---|
| 237 | component.addGlobalListener(forward); |
|---|
| 238 | _componentsLayer.addChildAt(component as DisplayObject, index); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | protected function resizeHandler(event:Event):void { |
|---|
| 243 | redraw(); |
|---|
| 244 | |
|---|
| 245 | var currentFSMode:Boolean = (RootReference.stage.displayState == StageDisplayState.FULL_SCREEN); |
|---|
| 246 | if (_model.fullscreen != currentFSMode) { |
|---|
| 247 | dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_FULLSCREEN, currentFSMode)); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | public function fullscreen(mode:Boolean=true):void { |
|---|
| 253 | RootReference.stage.displayState = mode ? StageDisplayState.FULL_SCREEN : StageDisplayState.NORMAL; |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | /** Redraws the plugins and player components **/ |
|---|
| 258 | public function redraw():void { |
|---|
| 259 | layoutManager.resize(RootReference.stage.stageWidth, RootReference.stage.stageHeight); |
|---|
| 260 | |
|---|
| 261 | _components.resize(_player.config.width, _player.config.height); |
|---|
| 262 | |
|---|
| 263 | resizeBackground(); |
|---|
| 264 | resizeMasker(); |
|---|
| 265 | |
|---|
| 266 | if (_imageLayer.numChildren) { |
|---|
| 267 | _imageLayer.x = _components.display.x; |
|---|
| 268 | _imageLayer.y = _components.display.y; |
|---|
| 269 | Stretcher.stretch(_image.loadedObject, _player.config.width, _player.config.height, _player.config.stretching); |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | if (_mediaLayer.numChildren && _model.media.display) { |
|---|
| 273 | _mediaLayer.x = _components.display.x; |
|---|
| 274 | _mediaLayer.y = _components.display.y; |
|---|
| 275 | _model.media.resize(_player.config.width, _player.config.height); |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | if (_logoLayer.numChildren) { |
|---|
| 279 | _logoLayer.x = _components.display.x; |
|---|
| 280 | _logoLayer.y = _components.display.y; |
|---|
| 281 | _logo.resize(_player.config.width, _player.config.height); |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | for (var i:Number = 0; i < _pluginsLayer.numChildren; i++) { |
|---|
| 285 | var plug:IPlugin = _pluginsLayer.getChildAt(i) as IPlugin; |
|---|
| 286 | var plugDisplay:DisplayObject = plug as DisplayObject; |
|---|
| 287 | if (plug && plugDisplay) { |
|---|
| 288 | var cfg:PluginConfig = _player.config.pluginConfig(plug.id); |
|---|
| 289 | if (cfg['visible']) { |
|---|
| 290 | plugDisplay.visible = true; |
|---|
| 291 | plugDisplay.x = cfg['x']; |
|---|
| 292 | plugDisplay.y = cfg['y']; |
|---|
| 293 | try { |
|---|
| 294 | plug.resize(cfg.width, cfg.height); |
|---|
| 295 | } catch (e:Error) { |
|---|
| 296 | Logger.log("There was an error resizing plugin '" + plug.id + "': " + e.message); |
|---|
| 297 | } |
|---|
| 298 | } else { |
|---|
| 299 | plugDisplay.visible = false; |
|---|
| 300 | } |
|---|
| 301 | } |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | PlayerV4Emulation.getInstance(_player).resize(_player.config.width, _player.config.height); |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | protected function resizeBackground():void { |
|---|
| 309 | var bg:DisplayObject = _backgroundLayer.getChildByName("background"); |
|---|
| 310 | bg.width = RootReference.stage.stageWidth; |
|---|
| 311 | bg.height = RootReference.stage.stageHeight; |
|---|
| 312 | bg.x = 0; |
|---|
| 313 | bg.y = 0; |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | protected function resizeMasker():void { |
|---|
| 318 | if (_displayMasker == null) |
|---|
| 319 | setupDisplayMask(); |
|---|
| 320 | |
|---|
| 321 | _displayMasker.graphics.clear(); |
|---|
| 322 | _displayMasker.graphics.beginFill(0, 1); |
|---|
| 323 | _displayMasker.graphics.drawRect(_components.display.x, _components.display.y, _player.config.width, _player.config.height); |
|---|
| 324 | _displayMasker.graphics.endFill(); |
|---|
| 325 | } |
|---|
| 326 | |
|---|
| 327 | |
|---|
| 328 | public function get components():IPlayerComponents { |
|---|
| 329 | return _components; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | public function overrideComponent(newComponent:IPlayerComponent):void { |
|---|
| 334 | if (newComponent is IControlbarComponent) { |
|---|
| 335 | // Replace controlbar |
|---|
| 336 | } else if (newComponent is IDisplayComponent) { |
|---|
| 337 | // Replace display |
|---|
| 338 | } else if (newComponent is IDockComponent) { |
|---|
| 339 | // Replace dock |
|---|
| 340 | } else if (newComponent is IPlaylistComponent) { |
|---|
| 341 | // Replace playlist |
|---|
| 342 | } else { |
|---|
| 343 | dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, "Component must implement a component interface")); |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | |
|---|
| 348 | public function addPlugin(id:String, plugin:IPlugin):void { |
|---|
| 349 | try { |
|---|
| 350 | var plugDO:DisplayObject = plugin as DisplayObject; |
|---|
| 351 | if (!_plugins[id] && plugDO != null) { |
|---|
| 352 | _plugins[id] = plugDO; |
|---|
| 353 | _pluginsLayer.addChild(plugDO); |
|---|
| 354 | //_pluginsLayer[id] = plugDO; |
|---|
| 355 | } |
|---|
| 356 | } catch (e:Error) { |
|---|
| 357 | dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, e.message)); |
|---|
| 358 | } |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | public function removePlugin(plugin:IPlugin):void { |
|---|
| 363 | var id:String = plugin.id.toLowerCase(); |
|---|
| 364 | if (id && _plugins[id] is IPlugin) { |
|---|
| 365 | _pluginsLayer.removeChild(_plugins[id]); |
|---|
| 366 | delete _plugins[id]; |
|---|
| 367 | } |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | |
|---|
| 371 | public function loadedPlugins():Array { |
|---|
| 372 | var list:Array = []; |
|---|
| 373 | for (var pluginId:String in _plugins) { |
|---|
| 374 | if (_plugins[pluginId] is IPlugin) { |
|---|
| 375 | list.push(pluginId); |
|---|
| 376 | } |
|---|
| 377 | } |
|---|
| 378 | return list; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | public function getPlugin(id:String):IPlugin { |
|---|
| 383 | return _plugins[id] as IPlugin; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | public function bringPluginToFront(id:String):void { |
|---|
| 388 | var plugin:IPlugin = getPlugin(id); |
|---|
| 389 | _pluginsLayer.setChildIndex(plugin as DisplayObject, _pluginsLayer.numChildren - 1); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | protected function mediaLoaded(evt:MediaEvent):void { |
|---|
| 394 | _mediaLayer.x = _components.display.x; |
|---|
| 395 | _mediaLayer.y = _components.display.y; |
|---|
| 396 | if (_model.media.display) { |
|---|
| 397 | _model.media.resize(_player.config.width, _player.config.height); |
|---|
| 398 | _mediaLayer.addChild(_model.media.display); |
|---|
| 399 | } |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | protected function itemHandler(evt:PlaylistEvent):void { |
|---|
| 404 | while (_mediaLayer.numChildren) { |
|---|
| 405 | _mediaLayer.removeChildAt(0); |
|---|
| 406 | } |
|---|
| 407 | if (_model.playlist.currentItem && _model.playlist.currentItem.image) { |
|---|
| 408 | loadImage(_model.playlist.currentItem.image); |
|---|
| 409 | |
|---|
| 410 | } |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | protected function loadImage(url:String):void { |
|---|
| 415 | while (_imageLayer.numChildren) { |
|---|
| 416 | _imageLayer.removeChildAt(0); |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | _image.load(url); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | protected function imageComplete(evt:Event):void { |
|---|
| 424 | if (_image && _image.loadedObject is Bitmap) { |
|---|
| 425 | Draw.smooth(_image.loadedObject as Bitmap); |
|---|
| 426 | _imageLayer.addChild(_image.loadedObject); |
|---|
| 427 | _imageLayer.x = _components.display.x; |
|---|
| 428 | _imageLayer.y = _components.display.y; |
|---|
| 429 | Stretcher.stretch(_image.loadedObject, _player.config.width, _player.config.height, _player.config.stretching); |
|---|
| 430 | } else { |
|---|
| 431 | Logger.log('Error loading preview image.'); |
|---|
| 432 | } |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | |
|---|
| 436 | protected function imageError(evt:ErrorEvent):void { |
|---|
| 437 | Logger.log('Error loading preview image: '+evt.text); |
|---|
| 438 | //dispatchEvent(new PlayerEvent(PlayerEvent.JWPLAYER_ERROR, evt.text)); |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | protected function stateHandler(evt:PlayerStateEvent):void { |
|---|
| 443 | switch (evt.newstate) { |
|---|
| 444 | case PlayerState.IDLE: |
|---|
| 445 | _imageLayer.visible = true; |
|---|
| 446 | _mediaLayer.visible = false; |
|---|
| 447 | _logoLayer.visible = false; |
|---|
| 448 | break; |
|---|
| 449 | case PlayerState.PLAYING: |
|---|
| 450 | if (_model.media.display) { |
|---|
| 451 | _imageLayer.visible = false; |
|---|
| 452 | _mediaLayer.visible = true; |
|---|
| 453 | } |
|---|
| 454 | _logoLayer.visible = true; |
|---|
| 455 | break; |
|---|
| 456 | } |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | protected function forward(evt:Event):void { |
|---|
| 461 | if (evt is PlayerEvent) |
|---|
| 462 | dispatchEvent(evt); |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | } |
|---|