16 } |
16 } |
17 var _container = document.getElementById(config.gui.container); |
17 var _container = document.getElementById(config.gui.container); |
18 _container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>'; |
18 _container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>'; |
19 this.sourceManager = new IriSP.Model.Directory(); |
19 this.sourceManager = new IriSP.Model.Directory(); |
20 this.config = config; |
20 this.config = config; |
21 this.callbackQueue = []; |
21 this.__events = {}; |
22 this.isLoaded = false; |
|
23 this.loadLibs(); |
22 this.loadLibs(); |
24 } |
23 } |
25 |
24 |
26 IriSP.Metadataplayer.prototype.toString = function() { |
25 IriSP.Metadataplayer.prototype.toString = function() { |
27 return 'Metadataplayer in #' + this.config.gui.container; |
26 return 'Metadataplayer in #' + this.config.gui.container; |
28 } |
27 } |
29 |
28 |
30 IriSP.Metadataplayer.prototype.deferCallback = function(_callback) { |
29 IriSP.Metadataplayer.prototype.on = function(_event, _callback) { |
31 var _this = this; |
30 if (typeof this.__events[_event] === "undefined") { |
32 IriSP._.defer(function() { |
31 this.__events[_event] = []; |
33 _callback.call(_this); |
32 } |
|
33 this.__events[_event].push(_callback); |
|
34 } |
|
35 |
|
36 IriSP.Metadataplayer.prototype.trigger = function(_event, _data) { |
|
37 var _element = this; |
|
38 IriSP._(this.__events[_event]).each(function(_callback) { |
|
39 _callback.call(_element, _data); |
34 }); |
40 }); |
35 } |
|
36 |
|
37 IriSP.Metadataplayer.prototype.handleCallbacks = function() { |
|
38 this.isLoaded = true; |
|
39 while (this.callbackQueue.length) { |
|
40 this.deferCallback(this.callbackQueue.splice(0,1)[0]); |
|
41 } |
|
42 } |
|
43 |
|
44 IriSP.Metadataplayer.prototype.onLoad = function(_callback) { |
|
45 if (this.isLoaded) { |
|
46 this.deferCallback(_callback); |
|
47 } else { |
|
48 this.callbackQueue.push(_callback); |
|
49 } |
|
50 } |
41 } |
51 |
42 |
52 IriSP.Metadataplayer.prototype.loadLibs = function() { |
43 IriSP.Metadataplayer.prototype.loadLibs = function() { |
53 IriSP.log("IriSP.Metadataplayer.prototype.loadLibs"); |
44 IriSP.log("IriSP.Metadataplayer.prototype.loadLibs"); |
54 var $L = $LAB |
45 var $L = $LAB |
98 IriSP._ = window._; |
89 IriSP._ = window._; |
99 } |
90 } |
100 IriSP.loadCss(IriSP.getLib("cssjQueryUI")); |
91 IriSP.loadCss(IriSP.getLib("cssjQueryUI")); |
101 IriSP.loadCss(this.config.gui.css); |
92 IriSP.loadCss(this.config.gui.css); |
102 |
93 |
103 this.videoData = this.loadMetadata(this.config.player.metadata); |
94 // this.videoData = this.loadMetadata(this.config.player.metadata); |
104 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
95 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
105 this.$.css({ |
96 this.$.css({ |
106 "width": this.config.gui.width, |
97 "width": this.config.gui.width, |
107 "clear": "both" |
98 "clear": "both" |
108 }); |
99 }); |
109 if (typeof this.config.gui.height !== "undefined") { |
100 if (typeof this.config.gui.height !== "undefined") { |
110 this.$.css("height", this.config.gui.height); |
101 this.$.css("height", this.config.gui.height); |
111 } |
102 } |
112 |
103 |
|
104 this.widgets = []; |
113 var _this = this; |
105 var _this = this; |
|
106 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
|
107 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
|
108 _this.widgets.push(_widget) |
|
109 }); |
|
110 }; |
|
111 this.$.find('.Ldt-Loader').detach(); |
|
112 /* |
114 this.videoData.onLoad(function() { |
113 this.videoData.onLoad(function() { |
115 _this.onVideoDataLoaded(); |
114 _this.onVideoDataLoaded(); |
116 }); |
115 }); |
|
116 */ |
117 } |
117 } |
118 |
118 |
119 IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) { |
119 IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) { |
120 if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") { |
120 if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") { |
121 _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format]; |
121 _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format]; |
316 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
317 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
317 _this.widgets.push(_widget) |
318 _this.widgets.push(_widget) |
318 }); |
319 }); |
319 }; |
320 }; |
320 this.$.find('.Ldt-Loader').detach(); |
321 this.$.find('.Ldt-Loader').detach(); |
321 this.handleCallbacks(); |
|
322 } |
322 } |
323 |
323 |
324 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
324 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
325 /* Creating containers if needed */ |
325 /* Creating containers if needed */ |
326 if (typeof _widgetConfig.container === "undefined") { |
326 if (typeof _widgetConfig.container === "undefined") { |