8 /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ |
8 /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ |
9 |
9 |
10 IriSP.Metadataplayer = function(config) { |
10 IriSP.Metadataplayer = function(config) { |
11 IriSP.log("IriSP.Metadataplayer constructor"); |
11 IriSP.log("IriSP.Metadataplayer constructor"); |
12 for (var key in IriSP.guiDefaults) { |
12 for (var key in IriSP.guiDefaults) { |
13 if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { |
13 if (IriSP.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) { |
14 config.gui[key] = IriSP.guiDefaults[key] |
14 config[key] = IriSP.guiDefaults[key] |
15 } |
15 } |
16 } |
16 } |
17 var _container = document.getElementById(config.gui.container); |
17 var _container = document.getElementById(config.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.__events = {}; |
21 this.__events = {}; |
22 this.loadLibs(); |
22 this.loadLibs(); |
23 } |
23 } |
24 |
24 |
25 IriSP.Metadataplayer.prototype.toString = function() { |
25 IriSP.Metadataplayer.prototype.toString = function() { |
26 return 'Metadataplayer in #' + this.config.gui.container; |
26 return 'Metadataplayer in #' + this.config.container; |
27 } |
27 } |
28 |
28 |
29 IriSP.Metadataplayer.prototype.on = function(_event, _callback) { |
29 IriSP.Metadataplayer.prototype.on = function(_event, _callback) { |
30 if (typeof this.__events[_event] === "undefined") { |
30 if (typeof this.__events[_event] === "undefined") { |
31 this.__events[_event] = []; |
31 this.__events[_event] = []; |
43 IriSP.Metadataplayer.prototype.loadLibs = function() { |
43 IriSP.Metadataplayer.prototype.loadLibs = function() { |
44 IriSP.log("IriSP.Metadataplayer.prototype.loadLibs"); |
44 IriSP.log("IriSP.Metadataplayer.prototype.loadLibs"); |
45 var $L = $LAB |
45 var $L = $LAB |
46 .script(IriSP.getLib("underscore")) |
46 .script(IriSP.getLib("underscore")) |
47 .script(IriSP.getLib("Mustache")) |
47 .script(IriSP.getLib("Mustache")) |
48 .script(IriSP.getLib("jQuery")) |
48 .script(IriSP.getLib("jQuery")); |
49 .script(IriSP.getLib("swfObject")); |
|
50 |
49 |
51 if (typeof JSON == "undefined") { |
50 if (typeof JSON == "undefined") { |
52 $L.script(IriSP.getLib("json")); |
51 $L.script(IriSP.getLib("json")); |
53 } |
52 } |
54 |
53 |
55 $L.wait() |
54 $L.wait() |
56 .script(IriSP.getLib("jQueryUI")); |
55 .script(IriSP.getLib("jQueryUI")); |
57 |
56 |
58 if (this.config.player.type === "jwplayer" || this.config.player.type === "auto") { |
|
59 $L.script(IriSP.getLib("jwplayer")); |
|
60 } |
|
61 |
|
62 if (this.config.player.type !== "jwplayer" && this.config.player.type !== "allocine" && this.config.player.type !== "dailymotion") { |
|
63 $L.script(IriSP.getLib("popcorn")); |
|
64 } |
|
65 |
|
66 /* widget specific requirements */ |
57 /* widget specific requirements */ |
67 for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { |
58 for(var _i = 0; _i < this.config.widgets.length; _i++) { |
68 var _t = this.config.gui.widgets[_i].type; |
59 var _t = this.config.widgets[_i].type; |
69 if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) { |
60 if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) { |
70 for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) { |
61 for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) { |
71 $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j])); |
62 $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j])); |
72 } |
63 } |
73 } |
64 } |
87 } |
78 } |
88 if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") { |
79 if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") { |
89 IriSP._ = window._; |
80 IriSP._ = window._; |
90 } |
81 } |
91 IriSP.loadCss(IriSP.getLib("cssjQueryUI")); |
82 IriSP.loadCss(IriSP.getLib("cssjQueryUI")); |
92 IriSP.loadCss(this.config.gui.css); |
83 IriSP.loadCss(this.config.css); |
93 |
84 |
94 // this.videoData = this.loadMetadata(this.config.player.metadata); |
85 // this.videoData = this.loadMetadata(this.config.player.metadata); |
95 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
86 this.$ = IriSP.jQuery('#' + this.config.container); |
96 this.$.css({ |
87 this.$.css({ |
97 "width": this.config.gui.width, |
88 "width": this.config.width, |
98 "clear": "both" |
89 "clear": "both" |
99 }); |
90 }); |
100 if (typeof this.config.gui.height !== "undefined") { |
91 if (typeof this.config.height !== "undefined") { |
101 this.$.css("height", this.config.gui.height); |
92 this.$.css("height", this.config.height); |
102 } |
93 } |
103 |
94 |
104 this.widgets = []; |
95 this.widgets = []; |
105 var _this = this; |
96 var _this = this; |
106 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
97 for(var i = 0; i < this.config.widgets.length; i++) { |
107 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
98 this.loadWidget(this.config.widgets[i], function(_widget) { |
108 _this.widgets.push(_widget) |
99 _this.widgets.push(_widget) |
109 }); |
100 }); |
110 }; |
101 }; |
111 this.$.find('.Ldt-Loader').detach(); |
102 this.$.find('.Ldt-Loader').detach(); |
112 /* |
103 /* |
311 |
302 |
312 /* Now Loading Widgets */ |
303 /* Now Loading Widgets */ |
313 |
304 |
314 this.widgets = []; |
305 this.widgets = []; |
315 var _this = this; |
306 var _this = this; |
316 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
307 for(var i = 0; i < this.config.widgets.length; i++) { |
317 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
308 this.loadWidget(this.config.widgets[i], function(_widget) { |
318 _this.widgets.push(_widget) |
309 _this.widgets.push(_widget) |
319 }); |
310 }); |
320 }; |
311 }; |
321 this.$.find('.Ldt-Loader').detach(); |
312 this.$.find('.Ldt-Loader').detach(); |
322 } |
313 } |
352 */ |
343 */ |
353 IriSP.Metadataplayer.prototype.layoutDivs = function(_name, _height) { |
344 IriSP.Metadataplayer.prototype.layoutDivs = function(_name, _height) { |
354 if (typeof(_name) === "undefined") { |
345 if (typeof(_name) === "undefined") { |
355 _name = ""; |
346 _name = ""; |
356 } |
347 } |
357 var newDiv = IriSP._.uniqueId(this.config.gui.container + "_widget_" + _name + "_"), |
348 var newDiv = IriSP._.uniqueId(this.config.container + "_widget_" + _name + "_"), |
358 spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"), |
349 spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"), |
359 divHtml = IriSP.jQuery('<div>') |
350 divHtml = IriSP.jQuery('<div>') |
360 .attr("id",newDiv) |
351 .attr("id",newDiv) |
361 .css({ |
352 .css({ |
362 width: this.config.gui.width + "px", |
353 width: this.config.width + "px", |
363 position: "relative", |
354 position: "relative", |
364 clear: "both" |
355 clear: "both" |
365 }), |
356 }), |
366 spacerHtml = IriSP.jQuery('<div>') |
357 spacerHtml = IriSP.jQuery('<div>') |
367 .attr("id",spacerDiv) |
358 .attr("id",spacerDiv) |
368 .css({ |
359 .css({ |
369 width: this.config.gui.width + "px", |
360 width: this.config.width + "px", |
370 height: this.config.gui.spacer_div_height + "px", |
361 height: this.config.spacer_div_height + "px", |
371 position: "relative", |
362 position: "relative", |
372 clear: "both" |
363 clear: "both" |
373 }); |
364 }); |
374 if (typeof _height !== "undefined") { |
365 if (typeof _height !== "undefined") { |
375 divHtml.css("height", _height); |
366 divHtml.css("height", _height); |