| 1 | /** |
|---|
| 2 | * Abstract player class, extended by all other players. |
|---|
| 3 | * Class loads config and file objects and sets up MCV triangle. |
|---|
| 4 | * |
|---|
| 5 | * @author Jeroen Wijering |
|---|
| 6 | * @version 1.9 |
|---|
| 7 | **/ |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | import com.jeroenwijering.players.*; |
|---|
| 11 | import com.jeroenwijering.feeds.*; |
|---|
| 12 | import com.jeroenwijering.utils.ConfigManager; |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | class com.jeroenwijering.players.AbstractPlayer implements FeedListener { |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | /** Object with all config values **/ |
|---|
| 19 | public var config:Object; |
|---|
| 20 | /** Object with all playlist items **/ |
|---|
| 21 | public var feeder:FeedManager; |
|---|
| 22 | /** reference to the controller **/ |
|---|
| 23 | public var controller:AbstractController; |
|---|
| 24 | /** reference to config management object **/ |
|---|
| 25 | private var manager:ConfigManager; |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | /** Player application startup. **/ |
|---|
| 29 | public function AbstractPlayer(tgt:MovieClip) { |
|---|
| 30 | var ref = this; |
|---|
| 31 | config["clip"] = tgt; |
|---|
| 32 | manager = new ConfigManager(true); |
|---|
| 33 | manager.onComplete = function() { ref.fillConfig(); }; |
|---|
| 34 | manager.loadConfig(config); |
|---|
| 35 | }; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | /** Complete config with some default values **/ |
|---|
| 39 | private function fillConfig() { |
|---|
| 40 | if(config['shownavigation'] == 'false') { |
|---|
| 41 | config['controlbar'] = 0; |
|---|
| 42 | } |
|---|
| 43 | if (config["searchbar"] == 'true' && config['height'] > 50) { |
|---|
| 44 | config["searchbar"] = 28; |
|---|
| 45 | } else { |
|---|
| 46 | config["searchbar"] = 0; |
|---|
| 47 | } |
|---|
| 48 | if (config["displayheight"] == undefined) { |
|---|
| 49 | config["displayheight"] = config["height"] - config['controlbar'] - config["searchbar"]; |
|---|
| 50 | } else if(config["displayheight"] >= config["height"] - config["searchbar"]) { |
|---|
| 51 | config["displayheight"] = config["height"] - config["searchbar"]; |
|---|
| 52 | } else { |
|---|
| 53 | config["displayheight"] = Number(config["displayheight"]); |
|---|
| 54 | } |
|---|
| 55 | if (config["displaywidth"] == undefined) { |
|---|
| 56 | config["displaywidth"] = config["width"]; |
|---|
| 57 | } else { |
|---|
| 58 | config["displaywidth"] = Number(config["displaywidth"]); |
|---|
| 59 | } |
|---|
| 60 | config["bwstreams"] == undefined ? loadFile(): checkStream(); |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | /** Placeholder function for bandwidth checking **/ |
|---|
| 66 | private function checkStream() {}; |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | /** Load the file or playlist **/ |
|---|
| 70 | private function loadFile(str:String) { |
|---|
| 71 | feeder = new FeedManager(true,config["enablejs"],config['prefix'],str); |
|---|
| 72 | feeder.addListener(this); |
|---|
| 73 | feeder.loadFile(config); |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | /** Invoked by the feedmanager **/ |
|---|
| 78 | public function onFeedUpdate(typ:String) { |
|---|
| 79 | if(controller == undefined) { |
|---|
| 80 | config["clip"]._visible = true; |
|---|
| 81 | config["clip"]._parent.activity._visible = false; |
|---|
| 82 | setupMCV(); |
|---|
| 83 | } |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | /** Setup all necessary MCV blocks. **/ |
|---|
| 88 | private function setupMCV() { |
|---|
| 89 | controller = new AbstractController(config,feeder); |
|---|
| 90 | var asv = new AbstractView(controller,config,feeder); |
|---|
| 91 | var vws:Array = new Array(asv); |
|---|
| 92 | var asm = new AbstractModel(vws,controller,config,feeder); |
|---|
| 93 | var mds:Array = new Array(asm); |
|---|
| 94 | controller.startMCV(mds); |
|---|
| 95 | }; |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | } |
|---|