| 1 | package com.longtailvideo.jwplayer.player { |
|---|
| 2 | import com.longtailvideo.jwplayer.controller.Controller; |
|---|
| 3 | import com.longtailvideo.jwplayer.model.Model; |
|---|
| 4 | import com.longtailvideo.jwplayer.model.PlayerConfig; |
|---|
| 5 | import com.longtailvideo.jwplayer.model.Playlist; |
|---|
| 6 | import com.longtailvideo.jwplayer.plugins.IPlugin; |
|---|
| 7 | import com.longtailvideo.jwplayer.view.ISkin; |
|---|
| 8 | import com.longtailvideo.jwplayer.view.View; |
|---|
| 9 | |
|---|
| 10 | import flash.display.Sprite; |
|---|
| 11 | import flash.events.Event; |
|---|
| 12 | import flash.utils.setTimeout; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * Sent when the player has been initialized and skins and plugins have been successfully loaded. |
|---|
| 16 | * |
|---|
| 17 | * @eventType com.longtailvideo.jwplayer.events.PlayerEvent.JWPLAYER_READY |
|---|
| 18 | */ |
|---|
| 19 | [Event(name="jwplayerReady", type = "com.longtailvideo.jwplayer.events.PlayerEvent")] |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Main class for JW Flash Media Player |
|---|
| 24 | * |
|---|
| 25 | * @author Pablo Schklowsky |
|---|
| 26 | */ |
|---|
| 27 | public class Player extends Sprite { |
|---|
| 28 | private var model:Model; |
|---|
| 29 | private var view:View; |
|---|
| 30 | private var controller:Controller; |
|---|
| 31 | |
|---|
| 32 | /** Player constructor **/ |
|---|
| 33 | public function Player() { |
|---|
| 34 | // Small pause to allow Javascript to catch up |
|---|
| 35 | setTimeout(initializePlayer, 50); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | /** Initialize the Player **/ |
|---|
| 39 | protected function initializePlayer():void { |
|---|
| 40 | model = new Model(); |
|---|
| 41 | view = new View(); |
|---|
| 42 | controller = new Controller(this, model, view); |
|---|
| 43 | |
|---|
| 44 | model.addGlobalListener(forward); |
|---|
| 45 | view.addGlobalListener(forward); |
|---|
| 46 | controller.addGlobalListener(forward); |
|---|
| 47 | |
|---|
| 48 | controller.setupPlayer(); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | /** |
|---|
| 52 | * Forwards all MVC events to interested listeners. |
|---|
| 53 | * @param event |
|---|
| 54 | */ |
|---|
| 55 | protected function forward(event:Event):void { |
|---|
| 56 | dispatchEvent(event); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * The player's current configuration |
|---|
| 61 | */ |
|---|
| 62 | public function get config():PlayerConfig { |
|---|
| 63 | return model.config; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | /** |
|---|
| 67 | * Reference to player's skin. If no skin has been loaded, returns null. |
|---|
| 68 | */ |
|---|
| 69 | public function get skin():ISkin { |
|---|
| 70 | return view.skin; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * The current player state |
|---|
| 75 | */ |
|---|
| 76 | public function get state():String { |
|---|
| 77 | return model.state; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | * The player's playlist |
|---|
| 82 | */ |
|---|
| 83 | public function get playlist():Playlist { |
|---|
| 84 | return model.playlist; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | * Set to true when the player is blocking playback. |
|---|
| 89 | */ |
|---|
| 90 | public function get isBlocking():Boolean { |
|---|
| 91 | return false; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | /** |
|---|
| 95 | * Request that the player block playback. When the Player is blocking, the currently playing stream is |
|---|
| 96 | * paused, and no new playback-related commands will be honored until <code>unblockPlayback</code> is |
|---|
| 97 | * called. |
|---|
| 98 | * |
|---|
| 99 | * @param target Reference to plugin requesting playback blocking |
|---|
| 100 | * @return <code>true</code>, if the blocking request is successful. If another plugin is blocking,returns |
|---|
| 101 | * <code>false</code>. |
|---|
| 102 | */ |
|---|
| 103 | public function blockPlayback(target:IPlugin):Boolean { |
|---|
| 104 | return false; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | /** |
|---|
| 108 | * Unblocks the player. If the player was buffering or playing when it was blocked, playback will resume. |
|---|
| 109 | * |
|---|
| 110 | * @param target Reference to the requesting plugin. |
|---|
| 111 | * @return <code>true</code>, if <code>target</code> had previously requested player blocking. |
|---|
| 112 | * |
|---|
| 113 | */ |
|---|
| 114 | public function unblockPlayback(target:IPlugin):Boolean { |
|---|
| 115 | return false; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | public function volume(volume:Number):Boolean { |
|---|
| 119 | return false; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | public function mute(state:Boolean=null):Boolean { |
|---|
| 123 | return false; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | public function play():Boolean { |
|---|
| 127 | return false; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | public function pause():Boolean { |
|---|
| 131 | return false; |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | public function stop():Boolean { |
|---|
| 135 | return false; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | public function seek(position:Number):Boolean { |
|---|
| 139 | return false; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | public function load(item:*):Boolean { |
|---|
| 143 | return false; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | public function playlistItem(index:Number):Boolean { |
|---|
| 147 | return false; |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | public function playlistNext():Boolean { |
|---|
| 151 | return false; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | public function playlistPrev():Boolean { |
|---|
| 155 | return false; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | public function redraw():Boolean { |
|---|
| 159 | return false; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | public function fullscreen(on:Boolean=true):Boolean { |
|---|
| 163 | return false; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | public function link(index:Number=NaN):Boolean { |
|---|
| 167 | return false; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | } |
|---|
| 171 | } |
|---|