162 this.config.player.video = _media.video.replace(_media.streamer,''); |
165 this.config.player.video = _media.video.replace(_media.streamer,''); |
163 } |
166 } |
164 } |
167 } |
165 |
168 |
166 } |
169 } |
167 this.configurePopcorn(); |
170 |
168 this.widgets = []; |
171 if (typeof this.config.player.video === "string" && this.config.player.url_transform === "function") { |
169 var _this = this; |
172 this.config.player.video = this.config.player.url_transform(this.config.player.video); |
170 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
173 } |
171 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
174 |
172 _this.widgets.push(_widget) |
175 var _pop, |
173 }); |
176 _divs = this.layoutDivs("video",this.config.player.height || undefined), |
174 }; |
177 containerDiv = _divs[0], |
175 this.$.find('.Ldt-Loader').detach(); |
178 spacerDiv = _divs[1], |
176 this.handleCallbacks(); |
|
177 } |
|
178 |
|
179 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
|
180 /* Creating containers if needed */ |
|
181 if (typeof _widgetConfig.container === "undefined") { |
|
182 var _divs = this.layoutDivs(_widgetConfig.type); |
|
183 _widgetConfig.container = _divs[0]; |
|
184 } |
|
185 |
|
186 var _this = this; |
|
187 |
|
188 if (typeof IriSP.Widgets[_widgetConfig.type] !== "undefined") { |
|
189 IriSP._.defer(function() { |
|
190 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
191 }); |
|
192 } else { |
|
193 /* Loading Widget CSS */ |
|
194 if (typeof IriSP.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof IriSP.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !IriSP.widgetsRequirements[_widgetConfig.type].noCss) { |
|
195 IriSP.loadCss(IriSP.widgetsDir + '/' + _widgetConfig.type + '.css'); |
|
196 } |
|
197 /* Loading Widget JS */ |
|
198 $LAB.script(IriSP.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() { |
|
199 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
200 }); |
|
201 } |
|
202 } |
|
203 |
|
204 IriSP.Metadataplayer.prototype.configurePopcorn = function() { |
|
205 IriSP.log("IriSP.Metadataplayer.prototype.configurePopcorn"); |
|
206 var pop, |
|
207 ret = this.layoutDivs("video",this.config.player.height || undefined), |
|
208 containerDiv = ret[0], |
|
209 spacerDiv = ret[1], |
|
210 _this = this, |
179 _this = this, |
211 _types = { |
180 _types = { |
212 "html5" : /\.(ogg|ogv|webm)$/, |
181 "html5" : /\.(ogg|ogv|webm)$/, |
213 "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, |
182 "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, |
214 "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ |
183 "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ |
242 } |
207 } |
243 if(this.config.player.hasOwnProperty("height")) { |
208 if(this.config.player.hasOwnProperty("height")) { |
244 _videoEl.attr("height", this.config.player.height); |
209 _videoEl.attr("height", this.config.player.height); |
245 } |
210 } |
246 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
211 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
247 pop = Popcorn("#" + _tmpId); |
212 _pop = Popcorn("#" + _tmpId); |
248 break; |
213 break; |
249 |
214 |
250 case "html5-audio": |
215 case "html5-audio": |
251 var _tmpId = Popcorn.guid("audio"), |
216 var _tmpId = Popcorn.guid("audio"), |
252 _videoEl = IriSP.jQuery('<audio>'); |
217 _videoEl = IriSP.jQuery('<audio>'); |
261 } |
226 } |
262 if(this.config.player.hasOwnProperty("height")) { |
227 if(this.config.player.hasOwnProperty("height")) { |
263 _videoEl.attr("height", this.config.player.height); |
228 _videoEl.attr("height", this.config.player.height); |
264 } |
229 } |
265 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
230 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
266 pop = Popcorn("#" + _tmpId); |
231 _pop = Popcorn("#" + _tmpId); |
267 break; |
232 break; |
268 |
233 |
269 case "jwplayer": |
234 case "jwplayer": |
270 var opts = IriSP.jQuery.extend({}, this.config.player); |
235 var opts = IriSP.jQuery.extend({}, this.config.player); |
271 delete opts.container; |
236 delete opts.container; |
278 } |
243 } |
279 |
244 |
280 if(!opts.hasOwnProperty("controlbar.position")) { |
245 if(!opts.hasOwnProperty("controlbar.position")) { |
281 opts["controlbar.position"] = "none"; |
246 opts["controlbar.position"] = "none"; |
282 } |
247 } |
283 pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); |
248 _pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); |
284 break; |
249 break; |
285 |
250 |
286 case "youtube": |
251 case "youtube": |
287 // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div. |
252 // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div. |
288 IriSP.jQuery("#" + containerDiv).css({ |
253 IriSP.jQuery("#" + containerDiv).css({ |
296 _params[_ppart[0]] = decodeURIComponent(_ppart[1]); |
261 _params[_ppart[0]] = decodeURIComponent(_ppart[1]); |
297 } |
262 } |
298 _params.controls = 0; |
263 _params.controls = 0; |
299 _params.modestbranding = 1; |
264 _params.modestbranding = 1; |
300 _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params); |
265 _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params); |
301 pop = Popcorn.youtube("#" + containerDiv, _url); |
266 _pop = Popcorn.youtube("#" + containerDiv, _url); |
302 break; |
267 break; |
303 |
268 |
304 case "dailymotion": |
269 case "dailymotion": |
305 pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, this.config.player); |
270 _pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, this.config.player); |
306 break; |
271 break; |
307 |
272 |
308 case "mashup": |
273 case "mashup": |
309 pop = new IriSP.PopcornReplacement.mashup("#" + containerDiv, this.config.player); |
274 _pop = new IriSP.PopcornReplacement.mashup("#" + containerDiv, this.config.player); |
310 break; |
275 break; |
311 |
276 |
312 case "allocine": |
277 case "allocine": |
313 /* pass the options as-is to the allocine player and let it handle everything */ |
278 _pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, this.config.player); |
314 pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, this.config.player); |
|
315 break; |
279 break; |
316 |
280 |
317 case "mashup-html": |
281 case "mashup-html": |
318 pop = new IriSP.PopcornReplacement.htmlMashup("#" + containerDiv, this.config.player, this.videoData); |
282 _pop = new IriSP.PopcornReplacement.htmlMashup("#" + containerDiv, this.config.player, this.videoData); |
319 break; |
283 break; |
320 |
284 |
321 default: |
285 default: |
322 pop = undefined; |
286 _pop = undefined; |
323 }; |
287 }; |
324 |
288 |
325 this.popcorn = pop; |
289 this.popcorn = _pop; |
|
290 |
|
291 /* Now Loading Widgets */ |
|
292 |
|
293 this.widgets = []; |
|
294 var _this = this; |
|
295 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
|
296 this.loadWidget(this.config.gui.widgets[i], function(_widget) { |
|
297 _this.widgets.push(_widget) |
|
298 }); |
|
299 }; |
|
300 this.$.find('.Ldt-Loader').detach(); |
|
301 this.handleCallbacks(); |
|
302 } |
|
303 |
|
304 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
|
305 /* Creating containers if needed */ |
|
306 if (typeof _widgetConfig.container === "undefined") { |
|
307 var _divs = this.layoutDivs(_widgetConfig.type); |
|
308 _widgetConfig.container = _divs[0]; |
|
309 } |
|
310 |
|
311 var _this = this; |
|
312 |
|
313 if (typeof IriSP.Widgets[_widgetConfig.type] !== "undefined") { |
|
314 IriSP._.defer(function() { |
|
315 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
316 }); |
|
317 } else { |
|
318 /* Loading Widget CSS */ |
|
319 if (typeof IriSP.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof IriSP.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !IriSP.widgetsRequirements[_widgetConfig.type].noCss) { |
|
320 IriSP.loadCss(IriSP.widgetsDir + '/' + _widgetConfig.type + '.css'); |
|
321 } |
|
322 /* Loading Widget JS */ |
|
323 $LAB.script(IriSP.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() { |
|
324 _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
325 }); |
|
326 } |
326 } |
327 } |
327 |
328 |
328 /** create a subdiv with an unique id, and a spacer div as well. |
329 /** create a subdiv with an unique id, and a spacer div as well. |
329 @param widgetName the name of the widget. |
330 @param widgetName the name of the widget. |
330 @return an array of the form [createdivId, spacerdivId]. |
331 @return an array of the form [createdivId, spacerdivId]. |