source: trunk/fl5/src/com/longtailvideo/jwplayer/view/View.as @ 386

Revision 386, 2.7 KB checked in by pablo, 4 years ago (diff)

Player4 emulation

Line 
1package com.longtailvideo.jwplayer.view {
2        import com.longtailvideo.jwplayer.events.GlobalEventDispatcher;
3        import com.longtailvideo.jwplayer.player.Player;
4        import com.longtailvideo.jwplayer.plugins.IPlugin;
5        import com.longtailvideo.jwplayer.plugins.PluginConfig;
6        import com.longtailvideo.jwplayer.utils.RootReference;
7       
8        import flash.display.DisplayObject;
9        import flash.display.MovieClip;
10        import flash.display.Stage;
11        import flash.events.ErrorEvent;
12
13       
14
15        public class View extends GlobalEventDispatcher {
16                private var _skin:ISkin;
17                private var _components:PlayerComponents;
18                private var _fullscreen:Boolean = false;
19               
20                private var _plugins:MovieClip;
21               
22                private var _player:Player;
23               
24                private var stage:Stage;
25
26                public function View(player:Player) {
27                        stage = RootReference.stage;
28                        _plugins = new MovieClip();
29                        _plugins.name = "plugins";
30                        stage.addChild(_plugins);
31                }
32               
33                public function set skin(skn:ISkin):void {
34                        _skin = skn;
35                        if (!_components) {
36                                _components = new PlayerComponents(skn);
37                        }
38                }
39               
40                public function get skin():ISkin {
41                        return _skin;
42                }
43               
44                public function fullscreen(mode:Boolean=true):void {
45                }
46
47                public function redraw():void {
48                        for (var i:Number=0; i < _plugins.numChildren; i++) {
49                                var plug:IPlugin = _plugins.getChildAt(i) as IPlugin;
50                                if (plug) {
51                                        var cfg:PluginConfig = _player.config.pluginConfig((plug as DisplayObject).name);
52                                        plug.resize(cfg.width, cfg.height);
53                                }
54                        }
55                }
56               
57                public function get components():PlayerComponents {
58                        return _components;
59                }
60               
61                public function overrideComponent(newComponent:*):void {
62                        if (newComponent is IControlbarComponent) {
63                                // Replace controlbar
64                        } else if (newComponent is IDisplayComponent) {
65                                // Replace display
66                        } else if (newComponent is IDockComponent) {
67                                // Replace dock
68                        } else if (newComponent is IPlaylistComponent) {
69                                // Replace playlist
70                        } else {
71                                throw(new Error("Component must implement a component interface"));
72                        }
73                }
74               
75                public function addPlugin(name:String, plugin:IPlugin):void {
76                        try {
77                                var plugDO:DisplayObject = plugin as DisplayObject;
78                       
79                                if (_plugins.getChildByName(name) == null && plugDO != null) {
80                                        plugDO.name = name;
81                                        _plugins.addChild(plugDO);
82                                        _plugins[name] = plugDO;                                       
83                                }
84                        } catch(e:Error) {
85                                dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, e.message));
86                        }
87                }
88
89                public function loadedPlugins():String {
90                        var list:Array = [];
91                        for each (var plugin:DisplayObject in _plugins) {
92                                if (plugin is IPlugin) {
93                                        list.push(plugin.name);
94                                }
95                        }
96                        return list.join(",");
97                }
98
99                public function getPlugin(name:String):IPlugin {
100                        return _plugins.getChildByName(name) as IPlugin;
101                }
102               
103        }
104}
Note: See TracBrowser for help on using the repository browser.