|
1 /* |
|
2 * |
|
3 * Copyright 2010 Institut de recherche et d'innovation |
|
4 * contributor(s) : Samuel Huron |
|
5 * |
|
6 * contact@iri.centrepompidou.fr |
|
7 * http://www.iri.centrepompidou.fr |
|
8 * |
|
9 * This software is a computer program whose purpose is to show and add annotations on a video . |
|
10 * This software is governed by the CeCILL-C license under French law and |
|
11 * abiding by the rules of distribution of free software. You can use, |
|
12 * modify and/ or redistribute the software under the terms of the CeCILL-C |
|
13 * license as circulated by CEA, CNRS and INRIA at the following URL |
|
14 * "http://www.cecill.info". |
|
15 * |
|
16 * The fact that you are presently reading this means that you have had |
|
17 * knowledge of the CeCILL-C license and that you accept its terms. |
|
18 */ |
|
19 |
|
20 if(window.__IriSP === undefined ){ var __IriSP={};} |
|
21 |
|
22 // Player Configuration |
|
23 __IriSP.config = undefined; |
|
24 __IriSP.configDefault = { |
|
25 metadata:{ |
|
26 format:'cinelab', |
|
27 src:'', |
|
28 load:'jsonp' |
|
29 }, |
|
30 gui:{ |
|
31 width:650, |
|
32 height:0, |
|
33 mode:'radio', |
|
34 container:'LdtPlayer', |
|
35 debug:false, |
|
36 css:'../src/css/LdtPlayer.css' |
|
37 }, |
|
38 player:{ |
|
39 type:'jwplayer', |
|
40 src:'../res/swf/player.swf', |
|
41 params:{ |
|
42 allowfullscreen:"true", |
|
43 allowscriptaccess:"always", |
|
44 wmode:"transparent" |
|
45 }, |
|
46 flashvars:{ |
|
47 streamer:"streamer", |
|
48 file:"file", |
|
49 live:"true", |
|
50 autostart:"true", |
|
51 controlbar:"none", |
|
52 playerready:"__IriSP.playerReady" |
|
53 }, |
|
54 attributes:{ |
|
55 id:"Ldtplayer1", |
|
56 name:"Ldtplayer1" |
|
57 } |
|
58 }, |
|
59 module:null |
|
60 }; |
|
61 |
|
62 __IriSP.lib = { |
|
63 jQuery:"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", |
|
64 jQueryUI:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js", |
|
65 jQueryToolTip:"http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js", |
|
66 swfObject:"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js", |
|
67 cssjQueryUI:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css" |
|
68 }; |
|
69 |
|
70 // Player Variable |
|
71 __IriSP.LdtShareTool = ""+ |
|
72 "\n<a onclick=\"__IriSP.MyApiPlayer.share('delicious');\" title='partager avec delicious'><span class='share shareDelicious'> </span></a>"+ |
|
73 "\n<a onclick=\"__IriSP.MyApiPlayer.share('facebook');\" title='partager avec facebook'> <span class='share shareFacebook'> </span></a>"+ |
|
74 "\n<a onclick=\"__IriSP.MyApiPlayer.share('twitter');\" title='partager avec twitter'> <span class='share shareTwitter'> </span></a>"+ |
|
75 "\n<a onclick=\"__IriSP.MyApiPlayer.share('myspace');\" title='partager avec Myspace'> <span class='share shareMySpace'> </span></a>"; |
|
76 |
|
77 // Official instance - to refactor ? |
|
78 __IriSP.MyLdt = null; |
|
79 __IriSP.MyTags = null; |
|
80 __IriSP.MyApiPlayer = null; |
|
81 __IriSP.player = null; |
|
82 |
|
83 // genral var (old code) - to refactor |
|
84 __IriSP.Durration = null; |
|
85 __IriSP.playerLdtWidth = null; |
|
86 __IriSP.playerLdtHeight = null; |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 __IriSP.init = function (config){ |
|
93 |
|
94 |
|
95 if(config === null){ |
|
96 |
|
97 __IriSP.config = __IriSP.configDefault; |
|
98 |
|
99 } else { |
|
100 |
|
101 __IriSP.config = config; |
|
102 |
|
103 |
|
104 |
|
105 if (__IriSP.config.player.params == null){ |
|
106 __IriSP.config.player.params = __IriSP.configDefault.player.params;} |
|
107 |
|
108 if (__IriSP.config.player.flashvars == null){ |
|
109 __IriSP.config.player.flashvars = __IriSP.configDefault.player.flashvars;} |
|
110 if (__IriSP.config.player.attributes == null){ |
|
111 __IriSP.config.player.attributes = __IriSP.configDefault.player.attributes;} |
|
112 } |
|
113 |
|
114 var metadataSrc = __IriSP.config.metadata.src; |
|
115 var guiContainer = __IriSP.config.gui.container; |
|
116 var guiMode = __IriSP.config.gui.mode; |
|
117 var guiLdtShareTool = __IriSP.LdtShareTool; |
|
118 // Localize jQuery variable |
|
119 __IriSP.jQuery = null; |
|
120 |
|
121 /******** Load jQuery if not present *********/ |
|
122 if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { |
|
123 var script_tag = document.createElement('script'); |
|
124 script_tag.setAttribute("type","text/javascript"); |
|
125 script_tag.setAttribute("src",__IriSP.lib.jQuery); |
|
126 //"http://cdn.jquerytools.org/1.2.4/full/jquery.tools.min.js"); |
|
127 script_tag.onload = scriptLibHandler; |
|
128 script_tag.onreadystatechange = function () { // Same thing but for IE |
|
129 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
|
130 scriptLibHandler(); |
|
131 |
|
132 } |
|
133 }; |
|
134 // Try to find the head, otherwise default to the documentElement |
|
135 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); |
|
136 } else { |
|
137 // The jQuery version on the window is the one we want to use |
|
138 __IriSP.jQuery = window.jQuery; |
|
139 scriptLibHandler(); |
|
140 } |
|
141 |
|
142 /******** Called once jQuery has loaded ******/ |
|
143 function scriptLibHandler() { |
|
144 |
|
145 var script_jqUi_tooltip = document.createElement('script'); |
|
146 script_jqUi_tooltip.setAttribute("type","text/javascript"); |
|
147 script_jqUi_tooltip.setAttribute("src",__IriSP.lib.jQueryToolTip); |
|
148 script_jqUi_tooltip.onload = scriptLoadHandler; |
|
149 script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE |
|
150 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
|
151 scriptLoadHandler("jquery.tools.min.js loded"); |
|
152 } |
|
153 }; |
|
154 |
|
155 var script_swfObj = document.createElement('script'); |
|
156 script_swfObj.setAttribute("type","text/javascript"); |
|
157 script_swfObj.setAttribute("src",__IriSP.lib.swfObject); |
|
158 script_swfObj.onload = scriptLoadHandler; |
|
159 script_swfObj.onreadystatechange = function () { // Same thing but for IE |
|
160 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
|
161 scriptLoadHandler("swfobject.js loded"); |
|
162 } |
|
163 }; |
|
164 |
|
165 var script_jqUi = document.createElement('script'); |
|
166 script_jqUi.setAttribute("type","text/javascript"); |
|
167 script_jqUi.setAttribute("src",__IriSP.lib.jQueryUI); |
|
168 script_jqUi.onload = scriptLoadHandler; |
|
169 script_jqUi.onreadystatechange = function () { // Same thing but for IE |
|
170 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
|
171 scriptLoadHandler("jquery-ui.min.js loded"); |
|
172 } |
|
173 }; |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi_tooltip); |
|
179 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi); |
|
180 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_swfObj); |
|
181 |
|
182 |
|
183 }; |
|
184 |
|
185 /******** Called once all lib are loaded ******/ |
|
186 var loadLib = 0; |
|
187 function scriptLoadHandler(Mylib) { |
|
188 //alert(Mylib); |
|
189 loadLib +=1; |
|
190 if(loadLib===3){ |
|
191 main(); |
|
192 }else { |
|
193 // __IriSP.jQuery('#'+__IriSP.config.gui.container).html("Loading library ..."); |
|
194 } |
|
195 }; |
|
196 |
|
197 /******** Our main function ********/ |
|
198 function main() { |
|
199 |
|
200 |
|
201 // Make __IriSP.jQuery and restore window.jQuery |
|
202 __IriSP.jQuery = window.jQuery.noConflict(true); |
|
203 // Call MY Jquery |
|
204 __IriSP.jQuery(document).ready(function($) { |
|
205 |
|
206 /******* Load CSS *******/ |
|
207 var css_link_jquery = __IriSP.jQuery("<link>", { |
|
208 rel: "stylesheet", |
|
209 type: "text/css", |
|
210 href: __IriSP.lib.cssjQueryUI, |
|
211 'class': "dynamic_css" |
|
212 }); |
|
213 var css_link_custom = __IriSP.jQuery("<link>", { |
|
214 rel: "stylesheet", |
|
215 type: "text/css", |
|
216 href: __IriSP.config.gui.css, |
|
217 'class': "dynamic_css" |
|
218 }); |
|
219 |
|
220 css_link_jquery.appendTo('head'); |
|
221 css_link_custom.appendTo('head'); |
|
222 |
|
223 // to see dynamicly loaded css on IE |
|
224 if ($.browser.msie) { |
|
225 $('.dynamic_css').clone().appendTo('head'); |
|
226 } |
|
227 |
|
228 //__IriSP.trace("main","ready createMyHtml"); |
|
229 |
|
230 __IriSP.createMyHtml(); |
|
231 //__IriSP.trace("main","end createMyHtml"); |
|
232 |
|
233 /******* Load Metadata *******/ |
|
234 |
|
235 __IriSP.jQuery.ajax({ |
|
236 dataType: __IriSP.config.metadata.load, |
|
237 url:metadataSrc, |
|
238 success : function(json){ |
|
239 |
|
240 __IriSP.trace("ajax","success"); |
|
241 |
|
242 // START PARSING ----------------------- |
|
243 if(json === ""){ |
|
244 alert("ERREUR DE CHARGEMENT JSON"); |
|
245 } else { |
|
246 |
|
247 |
|
248 // # CREATE MEDIA // |
|
249 // # JUSTE ONE PLAYER FOR THE MOMENT // |
|
250 //__IriSP.jQuery("<div></div>").appendTo("#output"); |
|
251 var MyMedia = new __IriSP.Media( |
|
252 json.medias[0].id, |
|
253 json.medias[0].href, |
|
254 json.medias[0]['meta']['dc:duration'], |
|
255 json.medias[0]['dc:title'], |
|
256 json.medias[0]['dc:description']); |
|
257 |
|
258 __IriSP.trace("__IriSP.MyApiPlayer", |
|
259 __IriSP.config.gui.width+" " |
|
260 + __IriSP.config.gui.height + " " |
|
261 + json.medias[0].href + " " |
|
262 + json.medias[0]['meta']['dc:duration'] + " " |
|
263 + json.medias[0]['meta']['item']['value']); |
|
264 |
|
265 // Create APIplayer |
|
266 __IriSP.MyApiPlayer = new __IriSP.APIplayer( |
|
267 __IriSP.config.gui.width, |
|
268 __IriSP.config.gui.height, |
|
269 json.medias[0].href, |
|
270 json.medias[0]['meta']['dc:duration'], |
|
271 json.medias[0]['meta']['item']['value']); |
|
272 |
|
273 // # CREATE THE FIRST LINE // |
|
274 __IriSP.trace("__IriSP.init.main","__IriSP.Ligne"); |
|
275 __IriSP.MyLdt = new __IriSP.Ligne ( |
|
276 json['annotation-types'][0].id, |
|
277 json['annotation-types'][0]['dc:title'], |
|
278 json['annotation-types'][0]['dc:description'], |
|
279 json.medias[0]['meta']['dc:duration']); |
|
280 |
|
281 // CREATE THE TAG CLOUD // |
|
282 __IriSP.trace("__IriSP.init.main","__IriSP.Tags"); |
|
283 __IriSP.MyTags = new __IriSP.Tags (json.tags); |
|
284 |
|
285 // CREATE THE ANNOTATIONS // |
|
286 // JUSTE FOR THE FIRST TYPE // |
|
287 __IriSP.jQuery.each(json.annotations, function(i,item) { |
|
288 if (item.meta['id-ref'] == __IriSP.MyLdt.id) { |
|
289 //__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation"); |
|
290 __IriSP.MyLdt.addAnnotation( |
|
291 item.id, |
|
292 item.begin, |
|
293 item.end, |
|
294 item.media, |
|
295 item.content.title, |
|
296 item.content.description, |
|
297 item.content.color, |
|
298 item.tags); |
|
299 } |
|
300 //MyTags.addAnnotation(item); |
|
301 }); |
|
302 __IriSP.jQuery.each(json.lists, function(i,item) { |
|
303 __IriSP.trace("lists",""); |
|
304 }); |
|
305 __IriSP.jQuery.each(json.views, function(i,item) { |
|
306 __IriSP.trace("views",""); |
|
307 }); |
|
308 } |
|
309 // END PARSING ----------------------- // |
|
310 |
|
311 |
|
312 },error : function(data){ |
|
313 alert("ERROR : "+data); |
|
314 } |
|
315 }); |
|
316 |
|
317 |
|
318 }); |
|
319 } |
|
320 |
|
321 }; |
|
322 |
|
323 |
|
324 __IriSP.createMyHtml = function(){ |
|
325 var width = __IriSP.config.gui.width; |
|
326 |
|
327 // AUDIO */ |
|
328 // PB dans le html : ; |
|
329 if(__IriSP.config.gui.mode=="radio"){ |
|
330 __IriSP.jQuery( "<div id='Ldt-Root'>\n"+ |
|
331 " <div id='Ldt-PlaceHolder'>\n"+ |
|
332 " <a href='http://www.adobe.com/go/getflashplayer'>Get flash</a> to see this player \n"+ |
|
333 " </div>\n"+ |
|
334 " <div id='Ldt-controler' class='demo'>\n"+ |
|
335 " <div class='Ldt-Control1' >\n"+ |
|
336 " <button id='ldt-CtrlPlay' onclick='__IriSP.MyApiPlayer.play()'>Lecture / Pause </button>\n"+ |
|
337 " <button id='ldt-CtrlNext' onclick='__IriSP.MyLdt.nextAnnotation()'>Suivant</button>\n"+ |
|
338 " </div>\n"+ |
|
339 " <div id='Ldt-Annotations' class='ui-slider'>\n"+ |
|
340 " <div id='slider-range-min'></div>\n"+ |
|
341 " </div>\n"+ |
|
342 " <div class='Ldt-Control2'>\n"+ |
|
343 " <button id='ldt-CtrlLink'> Partager </button>\n"+ |
|
344 " <button id='ldt-CtrlSound' onclick='__IriSP.MyApiPlayer.mute()'>Sound</button>\n"+ |
|
345 " </div>\n"+ |
|
346 " <div class='cleaner'> \;</div> \n"+ |
|
347 " <div id='Ldt-Show-Arrow-container'>\n"+ |
|
348 " <div id='Ldt-Show-Arrow'> </div>\n"+ |
|
349 " </div>\n"+ |
|
350 "</div>\n"+ |
|
351 "<div>\n"+ |
|
352 " <div id='ldt-Show'> </div>\n"+ |
|
353 " <div id='Ldt-ShowAnnotation-audio' class='demo' >\n"+ |
|
354 " <div id='Ldt-SaTitle'></div>\n"+ |
|
355 " <div id='Ldt-SaDescription'></div>\n"+ |
|
356 " <div class='cleaner'><!-- \;--></div>\n"+ |
|
357 " </div>\n"+ |
|
358 " <div id='Ldt-SaKeyword'>\n"+ |
|
359 " <div id='Ldt-SaKeywordText'> </div>\n"+ |
|
360 " <div class='cleaner'></div>\n"+ |
|
361 " <div id='Ldt-SaShareTools'>\n"+ |
|
362 " \n"+ |
|
363 " "+__IriSP.LdtShareTool+"\n"+ |
|
364 " \n"+ |
|
365 " </div>\n"+ |
|
366 " <div class='cleaner'></div>"+ |
|
367 "</div> "+ |
|
368 //"<div id='Ldt-Tags'> Mots clefs : </div>"+ |
|
369 "</div>"+ |
|
370 "<div id='Ldt-output'></div>").appendTo("#"+__IriSP.config.gui.container); |
|
371 } else if(__IriSP.config.gui.mode=="video") { |
|
372 |
|
373 __IriSP.jQuery( "<div id='Ldt-Root'>\n"+ |
|
374 " <div id='Ldt-PlaceHolder'>\n"+ |
|
375 " <a href='http://www.adobe.com/go/getflashplayer'>Get flash</a> to see this player \n"+ |
|
376 " </div>\n"+ |
|
377 " <div id='Ldt-controler' class='demo'>\n"+ |
|
378 " <div class='Ldt-Control1' >\n"+ |
|
379 " <button id='ldt-CtrlPlay' onclick='__IriSP.MyApiPlayer.play()'>Lecture / Pause </button>\n"+ |
|
380 " <button id='ldt-CtrlNext' onclick='__IriSP.MyLdt.nextAnnotation()'>Suivant</button>\n"+ |
|
381 " </div>\n"+ |
|
382 " <div id='Ldt-Annotations' class='ui-slider'>\n"+ |
|
383 " <div id='slider-range-min'></div>\n"+ |
|
384 " </div>\n"+ |
|
385 " <div class='Ldt-Control2'>\n"+ |
|
386 " <button id='ldt-CtrlLink'> Partager </button>\n"+ |
|
387 " <button id='ldt-CtrlSound' onclick='__IriSP.MyApiPlayer.mute()'>Sound</button>\n"+ |
|
388 " </div>\n"+ |
|
389 " <div class='cleaner'> \;</div> \n"+ |
|
390 " <div id='Ldt-Show-Arrow-container'>\n"+ |
|
391 " <div id='Ldt-Show-Arrow'> </div>\n"+ |
|
392 " </div>\n"+ |
|
393 "</div>\n"+ |
|
394 "<div>\n"+ |
|
395 " <div id='ldt-Show'> </div>\n"+ |
|
396 " <div id='Ldt-ShowAnnotation-audio' class='demo' >\n"+ |
|
397 " <div id='Ldt-SaTitle'></div>\n"+ |
|
398 " <div id='Ldt-SaDescription'></div>\n"+ |
|
399 " <div class='cleaner'><!-- \;--></div>\n"+ |
|
400 " </div>\n"+ |
|
401 " <div id='Ldt-SaKeyword'>\n"+ |
|
402 " <div id='Ldt-SaKeywordText'> </div>\n"+ |
|
403 " <div class='cleaner'></div>\n"+ |
|
404 " <div id='Ldt-SaShareTools'>\n"+ |
|
405 " \n"+ |
|
406 " "+__IriSP.LdtShareTool+"\n"+ |
|
407 " \n"+ |
|
408 " </div>\n"+ |
|
409 " <div class='cleaner'></div>"+ |
|
410 "</div> "+ |
|
411 //"<div id='Ldt-Tags'> Mots clefs : </div>"+ |
|
412 "</div>"+ |
|
413 "<div id='Ldt-output'></div>").appendTo("#"+__IriSP.config.gui.container); |
|
414 |
|
415 } |
|
416 |
|
417 |
|
418 __IriSP.trace("__IriSP.createHtml","end"); |
|
419 __IriSP.jQuery("#Ldt-Annotations").width(width-(75*2)); |
|
420 __IriSP.jQuery("#Ldt-Show-Arrow-container").width(width-(75*2)); |
|
421 __IriSP.jQuery("#Ldt-ShowAnnotation-audio").width(width-10); |
|
422 __IriSP.jQuery("#Ldt-ShowAnnotation-video").width(width-10); |
|
423 __IriSP.jQuery("#Ldt-SaKeyword").width(width-10); |
|
424 __IriSP.jQuery("#Ldt-controler").width(width-10); |
|
425 __IriSP.jQuery("#Ldt-Control").attr("z-index","100"); |
|
426 __IriSP.jQuery("#Ldt-controler").hide(); |
|
427 |
|
428 __IriSP.jQuery("<div id='Ldt-load-container'><div id='Ldt-loader'> </div> Chargement... </div>").appendTo("#Ldt-ShowAnnotation-audio"); |
|
429 |
|
430 if(__IriSP.config.gui.mode=='radio'){ |
|
431 __IriSP.jQuery("#Ldt-load-container").attr("width",__IriSP.config.gui.width); |
|
432 } |
|
433 // Show or not the output |
|
434 if(__IriSP.config.gui.debug===true){ |
|
435 __IriSP.jQuery("#Ldt-output").show(); |
|
436 } else { |
|
437 __IriSP.jQuery("#Ldt-output").hide(); |
|
438 } |
|
439 |
|
440 }; |
|
441 |
|
442 __IriSP.Media = function (id,url,duration,title,description){ |
|
443 this.id = id; |
|
444 this.url = url; |
|
445 this.title = title; |
|
446 this.description = description; |
|
447 this.duration = duration; |
|
448 this.lignes = new Array(); |
|
449 |
|
450 __IriSP.trace("__IriSP.Media","Media ID : "+id); |
|
451 __IriSP.trace("__IriSP.Media","Media URL : "+url); |
|
452 __IriSP.trace("__IriSP.Media","Media title : "+title); |
|
453 } |
|
454 __IriSP.Media.prototype.createPlayerMedia = function (width,height,MyStreamer,MySwfPath){ |
|
455 __IriSP.MyApiPlayer = new __IriSP.APIplayer(width,height,this.url,this.duration,MyStreamer,MySwfPath); |
|
456 //createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath); |
|
457 } |
|
458 __IriSP.Media.prototype.getMediaDuration = function (){ |
|
459 return (this.duration); |
|
460 } |
|
461 __IriSP.Media.prototype.getMediaTitle = function (){ |
|
462 return (this.title); |
|
463 } |
|
464 |
|
465 |
|
466 |
|
467 /* INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON () */ |
|
468 __IriSP.createInterface = function(width,height,duration){ |
|
469 |
|
470 __IriSP.jQuery("#Ldt-controler").show(); |
|
471 //__IriSP.jQuery("#Ldt-Root").css('display','visible'); |
|
472 __IriSP.trace("__IriSP.createInterface",width+","+height+","+duration+","); |
|
473 |
|
474 __IriSP.jQuery("#Ldt-ShowAnnotation").click(function () { |
|
475 //__IriSP.jQuery(this).slideUp(); |
|
476 }); |
|
477 |
|
478 var LdtpPlayerY = __IriSP.jQuery("#Ldt-PlaceHolder").attr("top"); |
|
479 var LdtpPlayerX = __IriSP.jQuery("#Ldt-PlaceHolder").attr("left"); |
|
480 __IriSP.jQuery("#slider-range-min").slider({ //range: "min", |
|
481 value: 0, |
|
482 min: 1, |
|
483 max: duration/1000,//1:54:52.66 = 3600+3240+ |
|
484 step: 0.1, |
|
485 slide: function(event, ui) { |
|
486 |
|
487 //__IriSP.jQuery("#amount").val(ui.value+" s"); |
|
488 //player.sendEvent('SEEK', ui.value) |
|
489 __IriSP.MyApiPlayer.seek(ui.value); |
|
490 //changePageUrlOffset(ui.value); |
|
491 //player.sendEvent('PAUSE') |
|
492 } |
|
493 }); |
|
494 __IriSP.trace("__IriSP.createInterface","ICI"); |
|
495 __IriSP.jQuery("#amount").val(__IriSP.jQuery("#slider-range-min").slider("value")+" s"); |
|
496 __IriSP.jQuery(".Ldt-Control1 button:first").button({ |
|
497 icons: { |
|
498 primary: 'ui-icon-play' |
|
499 }, |
|
500 text: false |
|
501 }).next().button({ |
|
502 icons: { |
|
503 primary: 'ui-icon-seek-next' |
|
504 }, |
|
505 text: false |
|
506 }); |
|
507 __IriSP.jQuery(".Ldt-Control2 button:first").button({ |
|
508 icons: { |
|
509 primary: 'ui-icon-transferthick-e-w'//, |
|
510 //secondary: 'ui-icon-volume-off' |
|
511 }, |
|
512 text: false |
|
513 }).next().button({ |
|
514 icons: { |
|
515 primary: 'ui-icon-volume-on' |
|
516 }, |
|
517 text: false |
|
518 }); |
|
519 |
|
520 // /!\ PB A MODIFIER |
|
521 //__IriSP.MyTags.draw(); |
|
522 __IriSP.trace("__IriSP.createInterface","ICI2"); |
|
523 __IriSP.jQuery("#ldt-CtrlPlay").attr("style","background-color:#CD21C24;"); |
|
524 |
|
525 __IriSP.jQuery("#Ldt-load-container").hide(); |
|
526 |
|
527 if(__IriSP.config.gui.mode=="radio" & __IriSP.jQuery.browser.msie!=true){ |
|
528 __IriSP.jQuery("#Ldtplayer1").attr("height","0"); |
|
529 } |
|
530 __IriSP.trace("__IriSP.createInterface","3"); |
|
531 |
|
532 __IriSP.trace("__IriSP.createInterface","END"); |
|
533 |
|
534 } |
|
535 |
|
536 |
|
537 /* API player - work in progress ... need refactoring of code */ |
|
538 __IriSP.APIplayer = function (width,height,url,duration,streamerPath,MySwfPath){ |
|
539 |
|
540 |
|
541 this.player = null; |
|
542 this.hashchangeUpdate = null; |
|
543 |
|
544 this.width = width; |
|
545 this.height = height; |
|
546 this.url = url; |
|
547 this.duration = duration; |
|
548 this.streamerPath = streamerPath; |
|
549 this.MySwfPath = MySwfPath; |
|
550 |
|
551 __IriSP.MyApiPlayer = this; |
|
552 |
|
553 __IriSP.createPlayer(this.url,this.streamerPath); |
|
554 __IriSP.trace("__IriSP.APIplayer","__IriSP.createPlayer"); |
|
555 |
|
556 //__IriSP.config.player |
|
557 /* |
|
558 - dailymotion // &enableApi=1&chromeless=1 |
|
559 - youtube |
|
560 - html5 |
|
561 - flowplayer |
|
562 - jwplayer |
|
563 */ |
|
564 |
|
565 } |
|
566 __IriSP.APIplayer.prototype.ready = function(player){ |
|
567 |
|
568 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface"); |
|
569 __IriSP.createInterface(this.width,this.height,this.duration); |
|
570 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady","END __IriSP.createInterface"); |
|
571 |
|
572 // hashchange EVENT |
|
573 if (window.addEventListener){ |
|
574 |
|
575 // pour FIREFOX hashchange EVENT |
|
576 window.addEventListener("hashchange", function() { |
|
577 var url = window.location.href; |
|
578 var time = __IriSP.retrieveTimeFragment(url); |
|
579 __IriSP.trace("__IriSP.APIplayer.prototype.ready",time); |
|
580 if(__IriSP.MyApiPlayer.hashchangeUpdate==null){ |
|
581 __IriSP.MyApiPlayer.seek(time); |
|
582 }else{ |
|
583 __IriSP.MyApiPlayer.hashchangeUpdate=null; |
|
584 } |
|
585 }, false); |
|
586 |
|
587 } |
|
588 else if (window.attachEvent){ |
|
589 // FOR IE hashchange EVENT |
|
590 |
|
591 window.attachEvent("onhashchange", function() { |
|
592 __IriSP.trace("hashchange",time); |
|
593 var url = window.location.href; |
|
594 var time = __IriSP.retrieveTimeFragment(url); |
|
595 if(__IriSP.MyApiPlayer.hashchangeUpdate==null){ |
|
596 __IriSP.MyApiPlayer.seek(time); |
|
597 }else{ |
|
598 __IriSP.MyApiPlayer.hashchangeUpdate=null; |
|
599 } |
|
600 }, false); |
|
601 } |
|
602 |
|
603 } |
|
604 __IriSP.APIplayer.prototype.pause = function(){ |
|
605 this.hashchangeUpdate = true; |
|
606 __IriSP.player.sendEvent('PAUSE'); |
|
607 } |
|
608 __IriSP.APIplayer.prototype.play = function(){ |
|
609 this.hashchangeUpdate = true; |
|
610 //__IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type); |
|
611 if(__IriSP.config.player.type=='jwplayer'){ |
|
612 |
|
613 __IriSP.player.sendEvent('PLAY'); |
|
614 |
|
615 } else if(__IriSP.config.player.type=='dailymotion' |
|
616 || __IriSP.config.player.type=='youtube') { |
|
617 |
|
618 var status = __IriSP.player.getPlayerState(); |
|
619 __IriSP.trace("__IriSP.APIplayer.prototype.play.status",status); |
|
620 if (status!=1){ |
|
621 __IriSP.player.playVideo(); |
|
622 }else{ |
|
623 __IriSP.player.pauseVideo(); |
|
624 } |
|
625 } |
|
626 } |
|
627 __IriSP.APIplayer.prototype.mute = function(){ |
|
628 __IriSP.player.sendEvent('MUTE'); |
|
629 |
|
630 //alert(__IriSP.jQuery(".ui-icon-volume-on").css("background-position-x")); |
|
631 if (__IriSP.jQuery(".ui-icon-volume-on").css("background-position")=="-144px -160px"){ |
|
632 __IriSP.jQuery(".ui-icon-volume-on").css("background-position","-130px -160px"); |
|
633 } else { |
|
634 __IriSP.jQuery(".ui-icon-volume-on").css("background-position","-144px -160px"); |
|
635 } |
|
636 } |
|
637 __IriSP.APIplayer.prototype.share = function(network){ |
|
638 |
|
639 var MyMessage = encodeURIComponent("J'écoute Les Retours du Dimanche : "); |
|
640 var MyURLNow = window.location.href; |
|
641 var shareURL; |
|
642 //alert(network+" : "+MyURLNow); |
|
643 |
|
644 if(network == "facebook"){ |
|
645 shareURL = "http://www.facebook.com/share.php?u="; |
|
646 }else if(network == "twitter"){ |
|
647 shareURL = "http://twitter.com/home?status="+MyMessage; |
|
648 }else if(network == "myspace"){ |
|
649 shareURL ="http://www.myspace.com/Modules/PostTo/Pages/?u="; |
|
650 }else if(network == "delicious"){ |
|
651 shareURL = "http://delicious.com/save?url="; |
|
652 }else if(network == "JameSpot"){ |
|
653 shareURL = "http://www.jamespot.com/?action=spotit&u="; |
|
654 //alert(network+" non actif pour l'instant : "+MyURLNow); |
|
655 } |
|
656 |
|
657 window.open(shareURL+encodeURIComponent(MyURLNow)); |
|
658 //window.location.href = shareURL+encodeURIComponent(MyURLNow); |
|
659 } |
|
660 __IriSP.APIplayer.prototype.seek = function (time){ |
|
661 __IriSP.trace("__IriSP.APIplayer.prototype.seek",time); |
|
662 if(__IriSP.config.player.type=='jwplayer'){ |
|
663 __IriSP.player.sendEvent('SEEK', time); |
|
664 } else if(__IriSP.config.player.type=='dailymotion' |
|
665 || __IriSP.config.player.type=='youtube') { |
|
666 __IriSP.player.seekTo(time); |
|
667 } |
|
668 this.changePageUrlOffset(time); |
|
669 } |
|
670 __IriSP.APIplayer.prototype.update = function (time){ |
|
671 this.hashchangeUpdate = true; |
|
672 __IriSP.player.sendEvent('SEEK', time); |
|
673 } |
|
674 __IriSP.APIplayer.prototype.changePageUrlOffset = function (time) { |
|
675 //alert(time); |
|
676 __IriSP.trace("__IriSP.APIplayer.prototype.changePageUrlOffset","CHANGE URL "+time); |
|
677 window.location.hash = "#t=" + time; |
|
678 window.location.href = window.location.href; |
|
679 } |
|
680 |
|
681 /* MEDIA FRAGMENT FUNCTION */ |
|
682 |
|
683 __IriSP.jumpToTimeoffset = function (form) { |
|
684 var time = form.time.value; |
|
685 __IriSP.MyApiPlayer.changePageUrlOffset(time); |
|
686 } |
|
687 __IriSP.retrieveTimeFragment = function (url) { |
|
688 var pageoffset = 0; |
|
689 var offsettime = 0; |
|
690 |
|
691 if (url.split("#")[1] != null) { |
|
692 pageoffset = url.split("#")[1]; |
|
693 if (pageoffset.substring(2) != null) { |
|
694 offsettime = pageoffset.substring(2); |
|
695 } |
|
696 } |
|
697 return offsettime; |
|
698 } |
|
699 __IriSP.ignoreTimeFragment = function(url){ |
|
700 if (url.split("#")[1] != null) { |
|
701 var pageurl= url.split("#")[0]; |
|
702 } |
|
703 return pageurl; |
|
704 } |
|
705 |
|
706 |
|
707 /* CODE SPECIAL JW PLAYER creation + listener */ |
|
708 |
|
709 __IriSP.currentPosition = 0; |
|
710 __IriSP.currentVolume = 50; |
|
711 __IriSP.player = null; |
|
712 __IriSP.startPosition = null; |
|
713 |
|
714 |
|
715 |
|
716 __IriSP.createPlayer = function (url,streamerPath) { |
|
717 |
|
718 |
|
719 if(__IriSP.config.player.type=='dailymotion'){ |
|
720 __IriSP.config.player.src = __IriSP.config.player.src+"&chromeless=1&enableApi=1"; |
|
721 } else if (__IriSP.config.player.type=='youtube'){ |
|
722 __IriSP.config.player.src = __IriSP.config.player.src+"&enablejsapi=1&version=3"; |
|
723 } |
|
724 |
|
725 __IriSP.trace("__IriSP.createPlayer","start"); |
|
726 |
|
727 __IriSP.myUrlFragment = url.split(streamerPath); |
|
728 __IriSP.config.player.flashvars.streamer = streamerPath; |
|
729 __IriSP.config.player.flashvars.file = __IriSP.myUrlFragment[1]; |
|
730 |
|
731 var flashvars = __IriSP.config.player.flashvars; |
|
732 var params = __IriSP.config.player.params; |
|
733 var attributes = __IriSP.config.player.attributes; |
|
734 |
|
735 __IriSP.trace( |
|
736 "__IriSP.createPlayer", |
|
737 "SWFOBJECT src:"+ |
|
738 __IriSP.config.player.src+ |
|
739 " " +__IriSP.config.gui.width+ |
|
740 " " +__IriSP.config.gui.height |
|
741 ); |
|
742 |
|
743 swfobject.embedSWF( |
|
744 __IriSP.config.player.src, |
|
745 "Ldt-PlaceHolder", |
|
746 __IriSP.config.gui.width, |
|
747 __IriSP.config.gui.height, |
|
748 "9.0.115", |
|
749 false, |
|
750 flashvars, |
|
751 params, |
|
752 attributes |
|
753 ); |
|
754 |
|
755 // need a methode to |
|
756 // re execute if this swf call does'nt work |
|
757 } |
|
758 |
|
759 /* API DAILYMOTION */ |
|
760 onDailymotionPlayerReady = function (playerid){ |
|
761 |
|
762 //alert(playerid); |
|
763 __IriSP.player = document.getElementById(__IriSP.config.player.attributes.id); |
|
764 __IriSP.MyApiPlayer.ready(__IriSP.player); |
|
765 |
|
766 var url = document.location.href; |
|
767 var time = __IriSP.retrieveTimeFragment(url); |
|
768 __IriSP.startPosition = time; |
|
769 __IriSP.DailymotionAddListeners(); |
|
770 |
|
771 __IriSP.MyApiPlayer.ready(playerid); |
|
772 } |
|
773 __IriSP.DailymotionAddListeners = function () { |
|
774 if (__IriSP.player) { |
|
775 __IriSP.trace("__IriSP.addListeners","ADD Listener "); |
|
776 //__IriSP.player.addEventListener("onStateChange", "__IriSP.DailymotionPositionListener"); |
|
777 setTimeout("__IriSP.DailymotionPositionListener()",100); |
|
778 __IriSP.DailymotionPositionListener(); |
|
779 __IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener"); |
|
780 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
|
781 } else { |
|
782 __IriSP.setTimeout("__IriSP.DailymotionAddListeners()",100); |
|
783 } |
|
784 } |
|
785 __IriSP.DailymotionPositionListener = function() { |
|
786 |
|
787 __IriSP.currentPosition = __IriSP.player.getCurrentTime(); |
|
788 //__IriSP.trace("__IriSP.DailymotionPositionListener",__IriSP.currentPosition); |
|
789 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
|
790 |
|
791 __IriSP.jQuery("#slider-range-min").slider("value",__IriSP.currentPosition); |
|
792 __IriSP.jQuery("#amount").val(__IriSP.currentPosition+" s"); |
|
793 // afficher annotation |
|
794 /*__IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
|
795 */ |
|
796 |
|
797 setTimeout("__IriSP.DailymotionPositionListener()",10); |
|
798 } |
|
799 |
|
800 /* API YOUTUBE */ |
|
801 onYouTubePlayerReady= function (playerid){ |
|
802 |
|
803 var url = document.location.href; |
|
804 var time = __IriSP.retrieveTimeFragment(url); |
|
805 __IriSP.player = document.getElementById(__IriSP.config.player.attributes.id); |
|
806 __IriSP.startPosition = time; |
|
807 |
|
808 __IriSP.MyApiPlayer.ready(__IriSP.player); |
|
809 |
|
810 __IriSP.MyApiPlayer.seek(time); |
|
811 __IriSP.MyApiPlayer.play(); |
|
812 |
|
813 |
|
814 __IriSP.YouTubeAddListeners(); |
|
815 __IriSP.trace("onYouTubePlayerReady=",time); |
|
816 //__IriSP.MyApiPlayer.ready(playerid); |
|
817 } |
|
818 __IriSP.YouTubeAddListeners = function () { |
|
819 if (__IriSP.player) { |
|
820 __IriSP.trace("__IriSP.addListeners","ADD Listener "); |
|
821 __IriSP.player.addEventListener("onStateChange", "__IriSP.YouTubeStateMonitor"); |
|
822 setTimeout("__IriSP.YouTubePositionListener()",100); |
|
823 __IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener"); |
|
824 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
|
825 } else { |
|
826 __IriSP.setTimeout("__IriSP.YouTubePositionListener()",100); |
|
827 } |
|
828 } |
|
829 __IriSP.YouTubePositionListener = function() { |
|
830 |
|
831 __IriSP.currentPosition = __IriSP.player.getCurrentTime(); |
|
832 //__IriSP.trace("__IriSP.YouTubePositionListener",__IriSP.currentPosition); |
|
833 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
|
834 |
|
835 __IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
|
836 __IriSP.jQuery("#slider-range-min").slider("value",__IriSP.currentPosition); |
|
837 __IriSP.jQuery("#amount").val(__IriSP.currentPosition+" s"); |
|
838 // afficher annotation |
|
839 __IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
|
840 |
|
841 |
|
842 setTimeout("__IriSP.YouTubePositionListener()",10); |
|
843 } |
|
844 __IriSP.YouTubeStateMonitor = function (obj) { |
|
845 __IriSP.player.addModelListener('__IriSP.YouTubeStateMonitor ', newstate); |
|
846 //alert(newstate+" "+obj.newstate); |
|
847 if(newstate == '2') |
|
848 { |
|
849 __IriSP.trace("__IriSP.stateMonitor","PAUSE"); |
|
850 __IriSP.MyApiPlayer.changePageUrlOffset(__IriSP.currentPosition); |
|
851 |
|
852 }else if (newstate == '1'){ |
|
853 // une fois la video prete a lire la déplacer au bon timecode |
|
854 if(__IriSP.startPosition!=null){ |
|
855 __IriSP.MyApiPlayer.update(__IriSP.startPosition); |
|
856 __IriSP.startPosition = null; |
|
857 } |
|
858 } |
|
859 else if (newstate == '-1'){ |
|
860 // une fois la video prete a lire la déplacer au bon timecode |
|
861 if(__IriSP.startPosition!=null){ |
|
862 __IriSP.MyApiPlayer.update(__IriSP.startPosition); |
|
863 __IriSP.startPosition = null; |
|
864 } |
|
865 } else if (newstate == '3'){ |
|
866 __IriSP.trace("__IriSP.stateMonitor","BUFFERING : "); |
|
867 //changePageUrlOffset(currentPosition); |
|
868 } |
|
869 |
|
870 } |
|
871 |
|
872 /* API JW PLAYER */ |
|
873 __IriSP.playerReady = function (thePlayer) { |
|
874 |
|
875 //__IriSP.trace("__IriSP.playerReady","PLAYER READY !!!!!!!!!!!!"); |
|
876 __IriSP.player = window.document[thePlayer.id]; |
|
877 //__IriSP.trace("__IriSP.playerReady","API CALL "+__IriSP.player); |
|
878 __IriSP.MyApiPlayer.ready(__IriSP.player); |
|
879 //__IriSP.trace("__IriSP.playerReady","API CALL END "); |
|
880 |
|
881 var url = document.location.href; |
|
882 var time = __IriSP.retrieveTimeFragment(url); |
|
883 //__IriSP.trace("__IriSP.playerReady"," "+url+" "+time ); |
|
884 __IriSP.startPosition = time; |
|
885 //__IriSP.trace("__IriSP.playerReady"," LISTENER LAUCHER"); |
|
886 __IriSP.addListeners(); |
|
887 //__IriSP.trace("__IriSP.playerReady"," LISTENER END"); |
|
888 |
|
889 } |
|
890 __IriSP.addListeners = function () { |
|
891 if (__IriSP.player) { |
|
892 __IriSP.trace("__IriSP.addListeners","ADD Listener "); |
|
893 __IriSP.player.addModelListener("TIME", "__IriSP.positionListener"); |
|
894 __IriSP.player.addControllerListener("VOLUME", "__IriSP.volumeListener"); |
|
895 __IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
|
896 } else { |
|
897 __IriSP.setTimeout("__IriSP.addListeners()",100); |
|
898 } |
|
899 |
|
900 // et changer les boutons |
|
901 } |
|
902 __IriSP.stateMonitor = function (obj) { |
|
903 |
|
904 |
|
905 |
|
906 if(obj.newstate == 'PAUSED') |
|
907 { |
|
908 __IriSP.trace("__IriSP.stateMonitor","PAUSE"); |
|
909 __IriSP.MyApiPlayer.changePageUrlOffset(__IriSP.currentPosition); |
|
910 __IriSP.jQuery(".ui-icon-play").css("background-position","0px -160px"); |
|
911 |
|
912 } else if (obj.newstate == 'PLAYING'){ |
|
913 // une fois la video prete a lire la déplacer au bon timecode |
|
914 if(__IriSP.startPosition!=null){ |
|
915 __IriSP.MyApiPlayer.update(__IriSP.startPosition); |
|
916 __IriSP.startPosition = null; |
|
917 } |
|
918 __IriSP.jQuery(".ui-icon-play").css("background-position","-16px -160px"); |
|
919 } else if (obj.newstate == 'BUFFERING'){ |
|
920 __IriSP.trace("__IriSP.stateMonitor","BUFFERING : "); |
|
921 //changePageUrlOffset(currentPosition); |
|
922 } |
|
923 |
|
924 } |
|
925 __IriSP.positionListener = function(obj) { |
|
926 //__IriSP.trace("__IriSP.positionListener",obj.position); |
|
927 __IriSP.currentPosition = obj.position; |
|
928 var tmp = document.getElementById("posit"); |
|
929 if (tmp) { tmp.innerHTML = "position: " + __IriSP.currentPosition; } |
|
930 __IriSP.jQuery("#slider-range-min").slider("value", obj.position); |
|
931 __IriSP.jQuery("#amount").val(obj.position+" s"); |
|
932 // afficher annotation |
|
933 __IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
|
934 |
|
935 |
|
936 } |
|
937 __IriSP.volumeListener = function (obj) { |
|
938 __IriSP.currentVolume = obj.percentage; |
|
939 var tmp = document.getElementById("vol"); |
|
940 if (tmp) { tmp.innerHTML = "volume: " + __IriSP.currentVolume; } |
|
941 } |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 /* UTIL */ |
|
947 // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript |
|
948 __IriSP.stripHtml = function(s){ |
|
949 return s.replace(/\\&/g, '&').replace(/\\</g, '<').replace(/\\>/g, '>').replace(/\\t/g, ' ').replace(/\\n/g, '<br />').replace(/'/g, ''').replace(/"/g, '"'); |
|
950 } |
|
951 // conversion de couleur Decimal vers HexaDecimal || 000 si fff |
|
952 __IriSP.DEC_HEXA_COLOR = function (dec){ |
|
953 var hexa='0123456789ABCDEF',hex=''; |
|
954 var tmp; |
|
955 while (dec>15){ |
|
956 tmp = dec-(Math.floor(dec/16))*16; |
|
957 hex = hexa.charAt(tmp)+hex; |
|
958 dec = Math.floor(dec/16); |
|
959 } |
|
960 hex = hexa.charAt(dec)+hex; |
|
961 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ } |
|
962 return(hex); |
|
963 } |
|
964 |
|
965 |
|
966 |
|
967 /* CLASS Ligne (annotationType) */ |
|
968 |
|
969 __IriSP.LDTligne = null; |
|
970 __IriSP.Ligne = function (id,title,description,duration){ |
|
971 this.id = id; |
|
972 this.title = title; |
|
973 this.description = description; |
|
974 // |
|
975 this.annotations = new Array(); |
|
976 this.duration = duration; |
|
977 this.annotationOldRead=""; |
|
978 __IriSP.LDTligne = this; |
|
979 __IriSP.trace("__IriSP.Ligne","CREATE "+__IriSP.LDTligne); |
|
980 } |
|
981 __IriSP.Ligne.prototype.addAnnotation = function (id,begin,end,media,title,description,color,tags){ |
|
982 var myAnnotation = new __IriSP.Annotation(id,begin,end,media,title,description,color,tags,this.duration); |
|
983 this.annotations.push(myAnnotation); |
|
984 //__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation ","add annotation "+title); |
|
985 } |
|
986 __IriSP.Ligne.prototype.onClickLigneAnnotation = function(id){ |
|
987 //changePageUrlOffset(currentPosition); |
|
988 //player.sendEvent('SEEK', this.start); |
|
989 //__IriSP.trace("SEEK",this.start); |
|
990 } |
|
991 __IriSP.Ligne.prototype.searchLigneAnnotation = function(id){ |
|
992 /*for (){ |
|
993 }*/ |
|
994 } |
|
995 __IriSP.Ligne.prototype.listAnnotations = function(){ |
|
996 |
|
997 } |
|
998 __IriSP.Ligne.prototype.nextAnnotation = function (){ |
|
999 var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1; |
|
1000 var annotationCible = this.annotations[annotationCibleNumber]; |
|
1001 |
|
1002 if(annotationCibleNumber<this.annotations.length-1){ |
|
1003 annotationCible.begin |
|
1004 __IriSP.player .sendEvent('SEEK', annotationCible.begin/1000); |
|
1005 __IriSP.trace("LIGNE ","| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000); |
|
1006 }else{ |
|
1007 __IriSP.player .sendEvent('SEEK', this.annotations[0].begin/1000); |
|
1008 } |
|
1009 |
|
1010 |
|
1011 } |
|
1012 __IriSP.Ligne.prototype.numAnnotation = function (annotationCible){ |
|
1013 for (var i=0; i < this.annotations.length; ++i){ |
|
1014 if(annotationCible == this.annotations[i]){ |
|
1015 return i; |
|
1016 } |
|
1017 } |
|
1018 } |
|
1019 __IriSP.Ligne.prototype.checkTime = function(time){ |
|
1020 var annotationTempo = -1; |
|
1021 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",time); |
|
1022 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",this.annotations.length); |
|
1023 |
|
1024 for (var i=0; i < this.annotations.length; ++i){ |
|
1025 annotationTempo = this.annotations[i]; |
|
1026 if (time>annotationTempo.begin/1000 && time<annotationTempo.end/1000){ |
|
1027 |
|
1028 // different form the previous |
|
1029 if(annotationTempo!=this.annotationOldRead){ |
|
1030 this.annotationOldRead = annotationTempo; |
|
1031 //__IriSP.trace("Check : ","annotation ici : "+i+" title "+annotationTempo.title); |
|
1032 //__IriSP.jQuery('#Ldt-ShowAnnotation').slideUp(); |
|
1033 //http://api.jquery.com/delay/ -> 1.4 |
|
1034 //__IriSP.jQuery("#Ldt-SaTitle").delay(100).text(annotationTempo.title); |
|
1035 //__IriSP.jQuery("#Ldt-SaDescription").delay(100).text(annotationTempo.description); |
|
1036 //__IriSP.jQuery('#Ldt-ShowAnnotation').delay(100).slideDown(); |
|
1037 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotationTempo.title+" "+annotationTempo.description ); |
|
1038 __IriSP.jQuery("#Ldt-SaTitle").text(annotationTempo.title); |
|
1039 __IriSP.jQuery("#Ldt-SaDescription").text(annotationTempo.description); |
|
1040 __IriSP.jQuery("#Ldt-SaKeywordText").html("Mots clefs : "+annotationTempo.htmlTags); |
|
1041 |
|
1042 //__IriSP.jQuery('#Ldt-ShowAnnotation').slideDown(); |
|
1043 var startPourcent = annotationTempo.timeToPourcent((annotationTempo.begin*1+(annotationTempo.end*1-annotationTempo.begin*1)/2),annotationTempo.duration*1); |
|
1044 __IriSP.jQuery("#Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000); |
|
1045 __IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000); |
|
1046 //alert(startPourcent); |
|
1047 var tempolinkurl = __IriSP.ignoreTimeFragment(window.location.href)+"#t="+(this.annotations[i].begin/1000); |
|
1048 } |
|
1049 break; |
|
1050 }else{ |
|
1051 annotationTempo=-1; |
|
1052 } |
|
1053 |
|
1054 } |
|
1055 // si il y en a pas : retractation du volet |
|
1056 if( annotationTempo == -1){ |
|
1057 if(annotationTempo!=this.annotationOldRead){ |
|
1058 __IriSP.trace("Check : ","pas d'annotation ici "); |
|
1059 __IriSP.jQuery("#Ldt-SaTitle").text(""); |
|
1060 __IriSP.jQuery("#Ldt-SaDescription").text(""); |
|
1061 __IriSP.jQuery("#Ldt-SaKeywordText").html(""); |
|
1062 __IriSP.jQuery('#Ldt-ShowAnnotation').slideUp(); |
|
1063 if(this.annotationOldRead){ |
|
1064 __IriSP.jQuery("#"+this.annotationOldRead.id).animate({alpha:'70%'},1000); |
|
1065 } |
|
1066 //__IriSP.jQuery("#Ldt-Show-Arrow").animate({left:'0%'},1000); |
|
1067 this.annotationOldRead = annotationTempo; |
|
1068 } |
|
1069 } |
|
1070 __IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotationTempo); |
|
1071 } |
|
1072 |
|
1073 |
|
1074 /* CLASS Annotation */ |
|
1075 |
|
1076 __IriSP.Annotation = function (){ |
|
1077 var id = null; |
|
1078 var begin = null; |
|
1079 var end = null; |
|
1080 var media = null; |
|
1081 var description = null; |
|
1082 var title = null; |
|
1083 var color = null; |
|
1084 var tags = null; |
|
1085 __IriSP.trace("annotation ","r�ussi") |
|
1086 } |
|
1087 __IriSP.Annotation = function(id,begin,end,media,title,description,color,tags,duration){ |
|
1088 this.id = id; |
|
1089 this.begin = begin; |
|
1090 this.end = end; |
|
1091 this.media = media; |
|
1092 this.description = description; |
|
1093 this.title = title; |
|
1094 this.color = color; |
|
1095 this.tags = tags; |
|
1096 this.htmlTags = ""; |
|
1097 this.duration = duration; |
|
1098 // draw it |
|
1099 this.draw(); |
|
1100 this.drawTags(); |
|
1101 // |
|
1102 __IriSP.trace("Annotation created : ",id); |
|
1103 } |
|
1104 __IriSP.Annotation.prototype.draw = function(){ |
|
1105 //alert (this.duration); |
|
1106 var startPourcent = this.timeToPourcent(this.begin,this.duration); // temps du media |
|
1107 var endPourcent = this.timeToPourcent(this.end,this.duration)-startPourcent; |
|
1108 var titleForDiv = this.title.substr(0,55); |
|
1109 |
|
1110 __IriSP.jQueryAnnotationTemplate = "<div title='"+__IriSP.stripHtml(titleForDiv)+"' id='"+this.id+"' class='ui-slider-range ui-slider-range-min ui-widget-header iri-chapter' width='100%' style=\"left:"+startPourcent+"%; width:"+endPourcent+"%; padding-top:15px; border-left:solid 1px #aaaaaa; border-right:solid 1px #aaaaaa; background:#"+__IriSP.DEC_HEXA_COLOR(this.color)+";\" onClick=\"__IriSP.MyApiPlayer.seek('"+Math.round(this.begin/1000)+"');__IriSP.jQuery('#Ldt-ShowAnnotation').slideDown();\" ></div> "; |
|
1111 //alert(this.color+" : "+DEC_HEXA_COLOR(this.color)); |
|
1112 |
|
1113 __IriSP.jQuerytoolTipTemplate = "<div class='Ldt-tooltip'>" |
|
1114 +"<div class='title'>"+__IriSP.stripHtml(this.title)+"</div>" |
|
1115 +"<div class='time'>"+this.begin+" : "+this.end+"</div>" |
|
1116 +"<div class='description'>"+__IriSP.stripHtml(this.description)+"</div>" |
|
1117 +"</div>"; |
|
1118 |
|
1119 |
|
1120 __IriSP.jQuery("<div>"+__IriSP.jQueryAnnotationTemplate+"</div>").appendTo("#Ldt-Annotations"); |
|
1121 // TOOLTIP BUG ! |
|
1122 |
|
1123 __IriSP.jQuery("#"+this.id).tooltip({ effect: 'slide'}); |
|
1124 |
|
1125 |
|
1126 __IriSP.jQuery("#"+this.id).fadeTo(0,0.3); |
|
1127 __IriSP.jQuery("#"+this.id).mouseover(function() { |
|
1128 __IriSP.jQuery("#"+this.id).animate({opacity: 0.6}, 5) |
|
1129 }).mouseout(function(){ |
|
1130 __IriSP.jQuery("#"+this.id).animate({opacity: 0.3}, 5) |
|
1131 }); |
|
1132 __IriSP.trace("__IriSP.Annotation.prototype.draw","ADD ANOTATION : "+this.begin+" "+this.end+" "+__IriSP.stripHtml(this.title)+" | "+startPourcent+" | "+endPourcent+" | duration = "+this.duration); |
|
1133 |
|
1134 } |
|
1135 __IriSP.Annotation.prototype.drawTags = function(){ |
|
1136 var KeywordPattern = '<a href=\"\"> '+' </a>'; |
|
1137 |
|
1138 //__IriSP.trace(" !? Tags : ",this.tags); |
|
1139 |
|
1140 if (this.tags!=undefined){ |
|
1141 for (var i = 0; i < this.tags.length; ++i){ |
|
1142 |
|
1143 //this.htmlTags += '<span onclick=\"ShowTag('+this.tags[i]['id-ref']+');\" > '+MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , "; |
|
1144 this.htmlTags += '<span> '+__IriSP.MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , "; |
|
1145 |
|
1146 } |
|
1147 } |
|
1148 } |
|
1149 __IriSP.Annotation.prototype.tootTipAnnotation = function() { |
|
1150 // 1 chercher le div correspondant |
|
1151 // 2 y mettre les information |
|
1152 return this.color + ' ' + this.type + ' apple'; |
|
1153 } |
|
1154 __IriSP.Annotation.prototype.onRollOverAnnotation = function (){ |
|
1155 this.tootTip(); |
|
1156 } |
|
1157 __IriSP.Annotation.prototype.timeToPourcent = function(time,timetotal){ |
|
1158 return (parseInt(Math.round(time/timetotal*100))); |
|
1159 } |
|
1160 |
|
1161 |
|
1162 /* CLASS Tags */ |
|
1163 |
|
1164 __IriSP.Tags = function(object){ |
|
1165 this.myTags = object; |
|
1166 this.htmlTags = null; |
|
1167 this.weigthMax = 0; |
|
1168 //this.mySegments = new array(); |
|
1169 } |
|
1170 __IriSP.Tags.prototype.addAnnotation = function (annotation){ |
|
1171 for (var i = 0; i < this.myTags.length; ++i){ |
|
1172 this.myTags[i].mySegments = new Array(); |
|
1173 if (annotation.tags!=null){ |
|
1174 for (var j = 0; j < annotation.tags.length; ++j){ |
|
1175 if (this.myTags[i]['id'] == annotation.tags[j]['id-ref']){ |
|
1176 this.myTags[i].mySegments.push([annotation.begin,annotation.end,annotation.id]); |
|
1177 var weigthTempo = this.myTags[i].mySegments.length |
|
1178 var tempo = this.myTags[i].mySegments[weigthTempo-1]; |
|
1179 //__IriSP.trace ("__IriSP.Tags.prototype.addAnnotation "," "+this.myTags[i]['meta']['dc:title']+" "+this.myTags[i]['id']+" : "+tempo[0]+" - "+tempo[1]); |
|
1180 |
|
1181 if (this.weigthMax < weigthTempo ){ |
|
1182 this.weigthMax = weigthTempo; |
|
1183 } |
|
1184 } |
|
1185 } |
|
1186 } |
|
1187 } |
|
1188 } |
|
1189 __IriSP.Tags.prototype.getTitle = function (id){ |
|
1190 for (var i = 0; i < this.myTags.length; ++i){ |
|
1191 if(this.myTags[i]['id']==id){ |
|
1192 return(this.myTags[i]['meta']['dc:title']); |
|
1193 } |
|
1194 } |
|
1195 |
|
1196 } |
|
1197 __IriSP.Tags.prototype.draw = function (){ |
|
1198 |
|
1199 __IriSP.trace("__IriSP.Tags.prototype.draw"," !!! WELL START " ); |
|
1200 for (var i = 0; i < this.myTags.length; ++i){ |
|
1201 __IriSP.trace("__IriSP.Tags.prototype.draw"," ADD Tags : "+this.myTags[i]['id']); |
|
1202 if(this.myTags[i]['id']!=null){ |
|
1203 this.htmlTags += '<span onclick=\"MyTags.show( \''+this.myTags[i]['id'] |
|
1204 +'\');\" style=\"font-size:' +((this.myTags[i].mySegments.length/this.weigthMax*10)+8) |
|
1205 +'px;\" alt=\"'+this.myTags[i].mySegments.length |
|
1206 +'\"> '+this.myTags[i]['meta']['dc:title']+' </span>'+' , '; |
|
1207 } |
|
1208 } |
|
1209 |
|
1210 __IriSP.jQuery('#Ldt-Tags').html(this.htmlTags); |
|
1211 __IriSP.trace("__IriSP.Tags.prototype.draw"," !!!! END WMAX= "+this.weigthMax ); |
|
1212 |
|
1213 } |
|
1214 __IriSP.Tags.prototype.show = function (id){ |
|
1215 |
|
1216 var timeStartOffsetA = 100000000000000000000; |
|
1217 var timeStartOffsetB = 100000000000000000000; |
|
1218 var timeEndOffsetA = 0; |
|
1219 var timeEndOffsetB = 0; |
|
1220 var timeStartID; |
|
1221 var timeEndID; |
|
1222 var WidthPourCent; |
|
1223 var leftPourCent; |
|
1224 var timeStartOffset; |
|
1225 |
|
1226 // case 1 : seul segment |
|
1227 // case 2 : 2 ou X segments |
|
1228 |
|
1229 |
|
1230 for (var i = 0; i < this.myTags.length; ++i){ |
|
1231 if (this.myTags[i]['id']==id){ |
|
1232 __IriSP.trace("######### TAG DRAWing : "," END" ); |
|
1233 |
|
1234 for (var j = 0; j < this.myTags[i].mySegments.length; ++j){ |
|
1235 if(timeStartOffset> this.myTags[i].mySegments[j][0]){ |
|
1236 timeStartOffsetA = this.myTags[i].mySegments[j][0]; |
|
1237 timeStartOffsetB = this.myTags[i].mySegments[j][1]; |
|
1238 timeStartID = this.myTags[i].mySegments[j][2] |
|
1239 } |
|
1240 if(timeStartOffset> this.myTags[i].mySegments[j][0]){ |
|
1241 timeEndOffsetA = this.myTags[i].mySegments[j][0]; |
|
1242 timeEndOffsetB = this.myTags[i].mySegments[j][1]; |
|
1243 timeEndID = this.myTags[i].mySegments[j][2] |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 } |
|
1248 } |
|
1249 |
|
1250 // ------------------------------------------------- |
|
1251 // |
|
1252 // ------------------------------------------------- |
|
1253 |
|
1254 leftPourCent = __IriSP.timeToPourcent((timeStartOffsetA*1+(timeStartOffsetB-timeStartOffsetA)/2),__IriSP.MyLdt.duration); |
|
1255 WidthPourCent = __IriSP.timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),__IriSP.MyLdt.duration)-leftPourCent; |
|
1256 //WidthPourCent = timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),MyLdt.duration)-startPourcent; |
|
1257 __IriSP.jQuery("#Ldt-Show-Tags").css('left',leftPourCent+'%'); |
|
1258 __IriSP.jQuery("#Ldt-Show-Tags").css('width',WidthPourCent+'%'); |
|
1259 // like arrow script |
|
1260 |
|
1261 |
|
1262 |
|
1263 } |
|
1264 |
|
1265 |
|
1266 /* CLASS TRACE */ |
|
1267 |
|
1268 __IriSP.traceNum=0; |
|
1269 __IriSP.trace = function(msg,value){ |
|
1270 |
|
1271 if(__IriSP.config.gui.debug===true){ |
|
1272 __IriSP.traceNum += 1; |
|
1273 __IriSP.jQuery("<div>"+__IriSP.traceNum+" - "+msg+" : "+value+"</div>").appendTo("#Ldt-output"); |
|
1274 } |
|
1275 |
|
1276 } |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |