117 if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") { |
111 if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") { |
118 return this.sourceManager.remoteSource(_metadataInfo); |
112 return this.sourceManager.remoteSource(_metadataInfo); |
119 } else { |
113 } else { |
120 return this.sourceManager.newLocalSource(_metadataInfo); |
114 return this.sourceManager.newLocalSource(_metadataInfo); |
121 } |
115 } |
122 } |
|
123 |
|
124 // TODO: REMOVE ! |
|
125 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { |
|
126 |
|
127 /* Setting default media from metadata */ |
|
128 |
|
129 if (typeof this.videoData !== "undefined") { |
|
130 |
|
131 var _media; |
|
132 |
|
133 if (typeof this.videoData.mainMedia !== "undefined") { |
|
134 _media = this.videoData.getElement(this.videoData.mainMedia); |
|
135 } |
|
136 |
|
137 if (this.config.player.type === "mashup" || this.config.player.type === "mashup-html") { |
|
138 if (typeof _media === "undefined" || _media.elementType !== "mashup") { |
|
139 var _mashups = this.videoData.getMashups(); |
|
140 if (_mashups.length) { |
|
141 _media = _mashups[0]; |
|
142 } |
|
143 } |
|
144 } else { |
|
145 if (typeof _media === "undefined" || _media.elementType !== "media") { |
|
146 var _medias = this.videoData.getMedias(); |
|
147 if (_medias.length) { |
|
148 _media = _medias[0]; |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 this.videoData.currentMedia = _media; |
|
154 |
|
155 /* Getting video URL from metadata if it's not in the player config options */ |
|
156 |
|
157 if (typeof _media !== "undefined" && typeof _media.video !== "undefined" && typeof this.config.player.video === "undefined") { |
|
158 this.config.player.video = _media.video; |
|
159 if (typeof this.config.player.streamer == "undefined" && typeof _media.streamer !== "undefined") { |
|
160 this.config.player.streamer = _media.streamer; |
|
161 } |
|
162 } |
|
163 |
|
164 } |
|
165 |
|
166 if (typeof this.config.player.video === "string" && this.config.player.url_transform === "function") { |
|
167 this.config.player.video = this.config.player.url_transform(this.config.player.video); |
|
168 } |
|
169 |
|
170 var _pop, |
|
171 _divs = this.layoutDivs("video",this.config.player.height || undefined), |
|
172 containerDiv = _divs[0], |
|
173 spacerDiv = _divs[1], |
|
174 _this = this, |
|
175 _types = { |
|
176 "html5" : /\.(ogg|ogv|webm)$/, |
|
177 "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, |
|
178 "vimeo" : /^(https?:\/\/)?(www\.)?vimeo\.com/, |
|
179 "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ |
|
180 }; |
|
181 |
|
182 if (this.config.player.type === "auto") { |
|
183 this.config.player.type = "jwplayer"; |
|
184 IriSP._(_types).each(function(_v, _k) { |
|
185 if (_v.test(_this.config.player.video)) { |
|
186 _this.config.player.type = _k |
|
187 } |
|
188 }); |
|
189 } |
|
190 |
|
191 switch(this.config.player.type) { |
|
192 case "html5": |
|
193 var _tmpId = Popcorn.guid("video"), |
|
194 _videoEl = IriSP.jQuery('<video>'); |
|
195 |
|
196 _videoEl.attr({ |
|
197 "src" : this.config.player.video, |
|
198 "id" : _tmpId |
|
199 }) |
|
200 |
|
201 if(this.config.player.hasOwnProperty("width")) { |
|
202 _videoEl.attr("width", this.config.player.width); |
|
203 } |
|
204 if(this.config.player.hasOwnProperty("height")) { |
|
205 _videoEl.attr("height", this.config.player.height); |
|
206 } |
|
207 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
|
208 _pop = Popcorn("#" + _tmpId); |
|
209 break; |
|
210 |
|
211 case "html5-audio": |
|
212 var _tmpId = Popcorn.guid("audio"), |
|
213 _videoEl = IriSP.jQuery('<audio>'); |
|
214 |
|
215 _videoEl.attr({ |
|
216 "src" : this.config.player.video, |
|
217 "id" : _tmpId |
|
218 }) |
|
219 |
|
220 if(this.config.player.hasOwnProperty("width")) { |
|
221 _videoEl.attr("width", this.config.player.width); |
|
222 } |
|
223 if(this.config.player.hasOwnProperty("height")) { |
|
224 _videoEl.attr("height", this.config.player.height); |
|
225 } |
|
226 IriSP.jQuery("#" + containerDiv).append(_videoEl); |
|
227 _pop = Popcorn("#" + _tmpId); |
|
228 break; |
|
229 |
|
230 case "jwplayer": |
|
231 var opts = IriSP.jQuery.extend({}, this.config.player); |
|
232 delete opts.container; |
|
233 delete opts.type; |
|
234 if (typeof opts.streamer === "function") { |
|
235 opts.streamer = opts.streamer(opts.video); |
|
236 } |
|
237 if (typeof opts.streamer === "string") { |
|
238 opts.video = opts.video.replace(opts.streamer,""); |
|
239 } |
|
240 opts.file = opts.video; |
|
241 delete opts.video; |
|
242 delete opts.metadata; |
|
243 |
|
244 if(!opts.hasOwnProperty("flashplayer")) { |
|
245 opts.flashplayer = IriSP.getLib("jwPlayerSWF"); |
|
246 } |
|
247 |
|
248 if(!opts.hasOwnProperty("controlbar.position")) { |
|
249 opts["controlbar.position"] = "none"; |
|
250 } |
|
251 _pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); |
|
252 break; |
|
253 |
|
254 case "youtube": |
|
255 // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div. |
|
256 IriSP.jQuery("#" + containerDiv).css({ |
|
257 width : this.config.player.width + "px", |
|
258 height : this.config.player.height + "px" |
|
259 }); |
|
260 var _urlparts = this.config.player.video.split(/[?&]/), |
|
261 _params = {}; |
|
262 for (var _j = 1; _j < _urlparts.length; _j++) { |
|
263 var _ppart = _urlparts[_j].split('='); |
|
264 _params[_ppart[0]] = decodeURIComponent(_ppart[1]); |
|
265 } |
|
266 _params.controls = 0; |
|
267 _params.modestbranding = 1; |
|
268 _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params); |
|
269 _pop = Popcorn.youtube("#" + containerDiv, _url); |
|
270 break; |
|
271 |
|
272 case "vimeo": |
|
273 // Popcorn.vimeo wants us to specify the size of the player in the style attribute of its container div. |
|
274 IriSP.jQuery("#" + containerDiv).css({ |
|
275 width : this.config.player.width + "px", |
|
276 height : this.config.player.height + "px" |
|
277 }); |
|
278 _pop = Popcorn.vimeo("#" + containerDiv, this.config.player.video); |
|
279 break; |
|
280 |
|
281 case "dailymotion": |
|
282 _pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, this.config.player); |
|
283 break; |
|
284 |
|
285 case "mashup": |
|
286 _pop = new IriSP.PopcornReplacement.mashup("#" + containerDiv, this.config.player); |
|
287 break; |
|
288 |
|
289 case "allocine": |
|
290 _pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, this.config.player); |
|
291 break; |
|
292 |
|
293 case "mashup-html": |
|
294 _pop = new IriSP.PopcornReplacement.htmlMashup("#" + containerDiv, this.config.player, this.videoData); |
|
295 break; |
|
296 |
|
297 default: |
|
298 _pop = undefined; |
|
299 }; |
|
300 |
|
301 this.popcorn = _pop; |
|
302 |
|
303 /* Now Loading Widgets */ |
|
304 |
|
305 this.widgets = []; |
|
306 var _this = this; |
|
307 for(var i = 0; i < this.config.widgets.length; i++) { |
|
308 this.loadWidget(this.config.widgets[i], function(_widget) { |
|
309 _this.widgets.push(_widget) |
|
310 }); |
|
311 }; |
|
312 this.$.find('.Ldt-Loader').detach(); |
|
313 } |
116 } |
314 |
117 |
315 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
118 IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
316 /* Creating containers if needed */ |
119 /* Creating containers if needed */ |
317 if (typeof _widgetConfig.container === "undefined") { |
120 if (typeof _widgetConfig.container === "undefined") { |