diff -r ff11367d4955 -r e9400c80e1e4 web/res/metadataplayer/LdtPlayer-core.js --- a/web/res/metadataplayer/LdtPlayer-core.js Mon Oct 15 14:34:47 2012 +0200 +++ b/web/res/metadataplayer/LdtPlayer-core.js Tue Oct 02 14:40:14 2012 +0200 @@ -20,11 +20,11 @@ v2.0.3 (c) Kyle Simpson MIT License */ -(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);/* init.js - initialization and configuration of Popcorn and the widgets +(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);/* init.js - initialization and configuration of the widgets */ if (typeof window.IriSP === "undefined") { - IriSP = {}; + window.IriSP = {}; } /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ @@ -32,43 +32,34 @@ IriSP.Metadataplayer = function(config) { IriSP.log("IriSP.Metadataplayer constructor"); for (var key in IriSP.guiDefaults) { - if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { - config.gui[key] = IriSP.guiDefaults[key] + if (IriSP.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) { + config[key] = IriSP.guiDefaults[key] } } - var _container = document.getElementById(config.gui.container); + var _container = document.getElementById(config.container); _container.innerHTML = '

Loading... Chargement...

'; this.sourceManager = new IriSP.Model.Directory(); this.config = config; - this.callbackQueue = []; - this.isLoaded = false; + this.__events = {}; this.loadLibs(); } IriSP.Metadataplayer.prototype.toString = function() { - return 'Metadataplayer in #' + this.config.gui.container; -} - -IriSP.Metadataplayer.prototype.deferCallback = function(_callback) { - var _this = this; - IriSP._.defer(function() { - _callback.call(_this); - }); + return 'Metadataplayer in #' + this.config.container; } -IriSP.Metadataplayer.prototype.handleCallbacks = function() { - this.isLoaded = true; - while (this.callbackQueue.length) { - this.deferCallback(this.callbackQueue.splice(0,1)[0]); +IriSP.Metadataplayer.prototype.on = function(_event, _callback) { + if (typeof this.__events[_event] === "undefined") { + this.__events[_event] = []; } + this.__events[_event].push(_callback); } -IriSP.Metadataplayer.prototype.onLoad = function(_callback) { - if (this.isLoaded) { - this.deferCallback(_callback); - } else { - this.callbackQueue.push(_callback); - } +IriSP.Metadataplayer.prototype.trigger = function(_event, _data) { + var _element = this; + IriSP._(this.__events[_event]).each(function(_callback) { + _callback.call(_element, _data); + }); } IriSP.Metadataplayer.prototype.loadLibs = function() { @@ -76,8 +67,7 @@ var $L = $LAB .script(IriSP.getLib("underscore")) .script(IriSP.getLib("Mustache")) - .script(IriSP.getLib("jQuery")) - .script(IriSP.getLib("swfObject")); + .script(IriSP.getLib("jQuery")); if (typeof JSON == "undefined") { $L.script(IriSP.getLib("json")); @@ -86,24 +76,18 @@ $L.wait() .script(IriSP.getLib("jQueryUI")); - if (this.config.player.type === "jwplayer" || this.config.player.type === "auto") { - $L.script(IriSP.getLib("jwplayer")); - } - - if (this.config.player.type !== "jwplayer" && this.config.player.type !== "allocine" && this.config.player.type !== "dailymotion") { - $L.script(IriSP.getLib("popcorn")); - } - /* widget specific requirements */ - for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { - var _t = this.config.gui.widgets[_i].type; - if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined") { - $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires)); + for(var _i = 0; _i < this.config.widgets.length; _i++) { + var _t = this.config.widgets[_i].type; + if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) { + for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) { + $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j])); + } } } var _this = this; - IriSP.log($L); + $L.wait(function() { _this.onLibsLoaded(); }); @@ -115,25 +99,28 @@ IriSP.jQuery = window.jQuery.noConflict(); } if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") { - IriSP._ = window._.noConflict(); + IriSP._ = window._; } IriSP.loadCss(IriSP.getLib("cssjQueryUI")); - IriSP.loadCss(this.config.gui.css); + IriSP.loadCss(this.config.css); - this.videoData = this.loadMetadata(this.config.player.metadata); - this.$ = IriSP.jQuery('#' + this.config.gui.container); + this.$ = IriSP.jQuery('#' + this.config.container); this.$.css({ - "width": this.config.gui.width, + "width": this.config.width, "clear": "both" }); - if (typeof this.config.gui.height !== "undefined") { - this.$.css("height", this.config.gui.height); + if (typeof this.config.height !== "undefined") { + this.$.css("height", this.config.height); } + this.widgets = []; var _this = this; - this.videoData.onLoad(function() { - _this.onVideoDataLoaded(); - }); + for(var i = 0; i < this.config.widgets.length; i++) { + this.loadWidget(this.config.widgets[i], function(_widget) { + _this.widgets.push(_widget) + }); + }; + this.$.find('.Ldt-Loader').detach(); } IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) { @@ -150,184 +137,6 @@ } } -IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { - - /* Setting default media from metadata */ - - if (typeof this.videoData !== "undefined") { - - var _media; - - if (typeof this.videoData.mainMedia !== "undefined") { - _media = this.videoData.getElement(this.videoData.mainMedia); - } - - if (this.config.player.type === "mashup" || this.config.player.type === "mashup-html") { - if (typeof _media === "undefined" || _media.elementType !== "mashup") { - var _mashups = this.videoData.getMashups(); - if (_mashups.length) { - _media = _mashups[0]; - } - } - } else { - if (typeof _media === "undefined" || _media.elementType !== "media") { - var _medias = this.videoData.getMedias(); - if (_medias.length) { - _media = _medias[0]; - } - } - } - - this.videoData.currentMedia = _media; - - /* Getting video URL from metadata if it's not in the player config options */ - - if (typeof _media !== "undefined" && typeof _media.video !== "undefined" && typeof this.config.player.video === "undefined") { - this.config.player.video = _media.video; - if (typeof this.config.player.streamer == "undefined" && typeof _media.streamer !== "undefined") { - this.config.player.streamer = _media.streamer; - } - } - - } - - if (typeof this.config.player.video === "string" && this.config.player.url_transform === "function") { - this.config.player.video = this.config.player.url_transform(this.config.player.video); - } - - var _pop, - _divs = this.layoutDivs("video",this.config.player.height || undefined), - containerDiv = _divs[0], - spacerDiv = _divs[1], - _this = this, - _types = { - "html5" : /\.(ogg|ogv|webm)$/, - "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, - "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ - }; - - if (this.config.player.type === "auto") { - this.config.player.type = "jwplayer"; - IriSP._(_types).each(function(_v, _k) { - if (_v.test(_this.config.player.video)) { - _this.config.player.type = _k - } - }); - } - - switch(this.config.player.type) { - case "html5": - var _tmpId = Popcorn.guid("video"), - _videoEl = IriSP.jQuery('