- Timestamp:
- 10/05/09 21:54:05 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fl5/src/com/longtailvideo/jwplayer/controller/Controller.as
r395 r396 1 1 package com.longtailvideo.jwplayer.controller { 2 2 import com.longtailvideo.jwplayer.events.GlobalEventDispatcher; 3 import com.longtailvideo.jwplayer.events.MediaEvent; 3 4 import com.longtailvideo.jwplayer.events.PlayerEvent; 4 5 import com.longtailvideo.jwplayer.events.PlaylistEvent; 6 import com.longtailvideo.jwplayer.events.ViewEvent; 5 7 import com.longtailvideo.jwplayer.model.Model; 6 8 import com.longtailvideo.jwplayer.model.PlaylistItem; … … 17 19 import flash.net.URLRequest; 18 20 import flash.net.navigateToURL; 19 import com.longtailvideo.jwplayer.events.MediaEvent;20 21 21 22 /** … … 50 51 /** File extensions of all supported mediatypes. **/ 51 52 private var extensions:Object = { 52 '3g2':'video',53 '3gp':'video',54 'aac':'video',55 'f4b':'video',56 'f4p':'video',57 'f4v':'video',58 'flv':'video',59 'gif':'image',60 'jpg':'image',61 'jpeg':'image',62 'm4a':'video',63 'm4v':'video',64 'mov':'video',65 'mp3':'sound',66 'mp4':'video',67 'png':'image',68 'rbs':'sound',69 'sdp':'video',70 'swf':'image',71 'vp6':'video'72 };53 '3g2':'video', 54 '3gp':'video', 55 'aac':'video', 56 'f4b':'video', 57 'f4p':'video', 58 'f4v':'video', 59 'flv':'video', 60 'gif':'image', 61 'jpg':'image', 62 'jpeg':'image', 63 'm4a':'video', 64 'm4v':'video', 65 'mov':'video', 66 'mp3':'sound', 67 'mp4':'video', 68 'png':'image', 69 'rbs':'sound', 70 'sdp':'video', 71 'swf':'image', 72 'vp6':'video' 73 }; 73 74 74 75 /** A list with legacy CDN classes that are now redirected to buit-in ones. **/ 75 76 private var cdns:Object = { 76 bitgravity:{'http.startparam':'starttime', provider:'http'},77 edgecast: {'http.startparam':'ec_seek',provider:'http'},78 flvseek: {'http.startparam':'fs',provider:'http'},79 highwinds: {'rtmp.loadbalance':true,provider:'rtmp'},80 lighttpd: {'http.startparam':'start',provider:'http'},81 vdox: {'rtmp.loadbalance':true,provider:'rtmp'}82 };77 bitgravity:{'http.startparam':'starttime', provider:'http'}, 78 edgecast:{'http.startparam':'ec_seek', provider:'http'}, 79 flvseek:{'http.startparam':'fs', provider:'http'}, 80 highwinds:{'rtmp.loadbalance':true, provider:'rtmp'}, 81 lighttpd:{'http.startparam':'start', provider:'http'}, 82 vdox:{'rtmp.loadbalance':true, provider:'rtmp'} 83 }; 83 84 84 85 public function Controller(player:Player, model:Model, view:View) { … … 106 107 107 108 private function addViewListeners():void { 108 109 _view.addEventListener(ViewEvent.JWPLAYER_VIEW_PLAY, playHandler); 110 _view.addEventListener(ViewEvent.JWPLAYER_VIEW_STOP, stopHandler); 111 } 112 113 private function playHandler(evt:Event):void { 114 if (_model.playlist.currentItem) { 115 switch (_player.state) { 116 case PlayerState.IDLE: 117 load(_model.playlist.currentItem); 118 break; 119 case PlayerState.PAUSED: 120 _model.media.play(); 121 break; 122 } 123 } 124 } 125 126 private function stopHandler(evt:ViewEvent):void { 127 switch (_player.state) { 128 case PlayerState.BUFFERING: 129 case PlayerState.PLAYING: 130 _model.media.stop(); 131 break; 132 } 109 133 } 110 134 … … 116 140 117 141 private function setupComplete(evt:Event):void { 118 trace("Setup complete");142 dispatchEvent(new PlayerEvent(PlayerEvent.JWPLAYER_READY)); 119 143 RootReference.stage.dispatchEvent(new Event(Event.RESIZE)); 144 loadFirstItem(); 120 145 } 121 146 … … 123 148 // This stuff moved to playlist item handler 124 149 } 125 150 126 151 private function playlistItemHandler(evt:PlaylistEvent):void { 127 152 var item:PlaylistItem = _model.playlist.currentItem; 128 153 if (item.provider) { 129 154 130 155 // Backwards compatibility for CDNs in the 'type' flashvar. 131 156 if (cdns.hasOwnProperty(item.provider)) { 132 157 _model.config.setConfig(cdns[item.provider]); 133 158 } 134 159 135 160 // If the model doesn't have an instance of the provider, load & instantiate it 136 161 if (!_model.hasMediaProvider(item.provider)) { … … 141 166 return; 142 167 } 143 } 144 145 load(_model.playlist.currentItem); 146 } 147 168 169 _model.setActiveMediaProvider(item.provider); 170 } 171 172 if (_player.config.autostart) { 173 load(_model.playlist.currentItem); 174 } 175 } 176 148 177 private function mediaSourceLoaded(evt:Event):void { 149 178 var loader:MediaProviderLoader = evt.target as MediaProviderLoader; 150 179 _model.setMediaProvider(_model.playlist.currentItem.provider, loader.loadedSource); 180 _model.setActiveMediaProvider(_model.playlist.currentItem.provider); 151 181 load(_model.playlist.currentItem); 152 182 } 153 183 154 184 private function errorHandler(evt:ErrorEvent):void { 155 185 errorState(evt.text); … … 334 364 return false; 335 365 } 336 366 337 367 private function lockHandler(evt:MediaEvent):void { 338 368 _model.media.play(); … … 361 391 return false; 362 392 } 393 394 private function loadFirstItem():void { 395 // if (_model.playlist.currentItem) { 396 // load(_model.playlist.currentItem); 397 // } 398 } 399 363 400 364 401 }
Note: See TracChangeset
for help on using the changeset viewer.
