|
1 /* ---------------------------------------------------------------- |
|
2 ---------------------------------------------------------------- |
|
3 ---------------------------------------------------------------- |
|
4 |
|
5 LDTPlayer is created by http://www.iri.centrepompidou.fr |
|
6 2010-06-10 |
|
7 |
|
8 Initiated By Samuel Huron < samuel.huron (at) cybunk (dot) com |
|
9 this version is the 0.06 |
|
10 |
|
11 ---------------------------------------------------------------- |
|
12 */ |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 /* ---------------------------------------------------------------- |
|
18 ---------------------------------------------------------------- |
|
19 INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON () */ |
|
20 |
|
21 |
|
22 function createInterface (width,height,duration){ |
|
23 $jIRI(function() { |
|
24 |
|
25 $jIRI("#Annotations").width(width-(78*2)); |
|
26 $jIRI("#ShowAnnotation").width(width-10); |
|
27 $jIRI("#controlerLdt").width(width); |
|
28 $jIRI("#Ldtplayer1").attr("z-index","100"); |
|
29 |
|
30 $jIRI("#ShowAnnotation").click(function () { |
|
31 $jIRI(this).slideUp(); |
|
32 }); |
|
33 |
|
34 var LdtpPlayerY = $jIRI("#ldtPlaceHolder").attr("top"); |
|
35 var LdtpPlayerX = $jIRI("#ldtPlaceHolder").attr("left"); |
|
36 |
|
37 //alert(LdtpPlayerY+" | "+LdtpPlayerX); |
|
38 //$jIRI("#ShowAnnotation").attr("position","absolute"); |
|
39 /*$jIRI("#ShowAnnotation").attr("top",0); |
|
40 $jIRI("#ShowAnnotation").attr("left",0);*/ |
|
41 |
|
42 //$jIRI("#slider-range-min").roll |
|
43 $jIRI("#slider-range-min").slider({ //range: "min", |
|
44 value: 0, |
|
45 min: 1, |
|
46 max: duration/1000,//1:54:52.66 = 3600+3240+ |
|
47 step: 0.1, |
|
48 slide: function(event, ui) { |
|
49 |
|
50 //$jIRI("#amount").val(ui.value+" s"); |
|
51 player.sendEvent('SEEK', ui.value) |
|
52 //player.sendEvent('PAUSE') |
|
53 } |
|
54 }); |
|
55 $jIRI("#amount").val($jIRI("#slider-range-min").slider("value")+" s"); |
|
56 |
|
57 $jIRI(".ldtControl1 button:first").button({ |
|
58 icons: { |
|
59 primary: 'ui-icon-play' |
|
60 }, |
|
61 text: false |
|
62 }).next().button({ |
|
63 icons: { |
|
64 primary: 'ui-icon-seek-next' |
|
65 }, |
|
66 text: false |
|
67 }); |
|
68 |
|
69 $jIRI(".ldtControl2 button:first").button({ |
|
70 icons: { |
|
71 primary: 'ui-icon-newwin'//, |
|
72 //secondary: 'ui-icon-volume-off' |
|
73 }, |
|
74 text: false |
|
75 }).next().button({ |
|
76 icons: { |
|
77 primary: 'ui-icon-volume-on' |
|
78 }, |
|
79 text: false |
|
80 }); |
|
81 |
|
82 }); |
|
83 } |
|
84 |
|
85 /* ---------------------------------------------------------------- |
|
86 ---------------------------------------------------------------- |
|
87 CREER JW PLAYER creation + listener */ |
|
88 |
|
89 |
|
90 var currentPosition = 0; |
|
91 var currentVolume = 50; |
|
92 var player = null; |
|
93 |
|
94 function playerReady(thePlayer) { |
|
95 //alert("ready"); |
|
96 player = window.document[thePlayer.id]; |
|
97 addListeners(); |
|
98 } |
|
99 |
|
100 function addListeners() { |
|
101 if (player) { |
|
102 player.addModelListener("TIME", "positionListener"); |
|
103 player.addControllerListener("VOLUME", "volumeListener"); |
|
104 player.addPlayPauseListener("PLAY", "state"); |
|
105 } else { |
|
106 setTimeout("addListeners()",100); |
|
107 } |
|
108 |
|
109 // et changer les boutons |
|
110 } |
|
111 |
|
112 //function |
|
113 |
|
114 function addPlayPauseListener(obj) { |
|
115 if(obj){ |
|
116 $jIRI(".control1 button:first").button({ |
|
117 icons: { |
|
118 primary: 'ui-icon-pause' |
|
119 }, |
|
120 text: false |
|
121 }); |
|
122 }else{ |
|
123 $jIRI(".control1 button:first").button({ |
|
124 icons: { |
|
125 primary: 'ui-icon-play' |
|
126 }, |
|
127 text: false |
|
128 }); |
|
129 } |
|
130 } |
|
131 |
|
132 function positionListener(obj) { |
|
133 currentPosition = obj.position; |
|
134 var tmp = document.getElementById("posit"); |
|
135 if (tmp) { tmp.innerHTML = "position: " + currentPosition; } |
|
136 $jIRI("#slider-range-min").slider("value", obj.position); |
|
137 $jIRI("#amount").val(obj.position+" s"); |
|
138 // afficher annotation |
|
139 |
|
140 MyLdt.checkTime(currentPosition); |
|
141 } |
|
142 |
|
143 function volumeListener(obj) { |
|
144 currentVolume = obj.percentage; |
|
145 var tmp = document.getElementById("vol"); |
|
146 if (tmp) { tmp.innerHTML = "volume: " + currentVolume; } |
|
147 } |
|
148 |
|
149 function createPlayer(width,height,url) { |
|
150 |
|
151 myUrlFragment = url.split("/"); |
|
152 // |
|
153 file = myUrlFragment[myUrlFragment.length-3]+"/"+myUrlFragment[myUrlFragment.length-2]+"/"+myUrlFragment[myUrlFragment.length-1]; |
|
154 indexofff = url.lastIndexOf(file); |
|
155 streamer = url.substr(0,indexofff); |
|
156 alert(url+"="+streamer+" - "+file); |
|
157 |
|
158 var flashvars = { |
|
159 streamer:streamer, |
|
160 file:file, |
|
161 //live:"true", |
|
162 autostart:"true", |
|
163 controlbar:"none" |
|
164 } |
|
165 |
|
166 var params = { |
|
167 allowfullscreen:"true", |
|
168 allowscriptaccess:"always", |
|
169 wmode:"transparent" |
|
170 } |
|
171 |
|
172 var attributes = { |
|
173 id:"Ldtplayer1", |
|
174 name:"Ldtplayer1" |
|
175 } |
|
176 |
|
177 swfobject.embedSWF("swf/player.swf", "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes); |
|
178 } |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 /* ---------------------------------------------------------------- |
|
186 ---------------------------------------------------------------- |
|
187 |
|
188 LOAD JSON AND PARSE IT |
|
189 */ |
|
190 |
|
191 |
|
192 var MyLdt; |
|
193 var Durration; |
|
194 var playerLdtWidth; |
|
195 var playerLdtHeight; |
|
196 |
|
197 function loadJson (width,height,urlJson){ |
|
198 |
|
199 playerLdtWidth=width; |
|
200 playerLdtHeight=height; |
|
201 |
|
202 $jIRI.ajax({ |
|
203 dataType: 'jsonp', |
|
204 url:urlJson, |
|
205 success: function(json){ |
|
206 |
|
207 //alert("success !"); |
|
208 |
|
209 |
|
210 } |
|
211 ,error: function(data){ |
|
212 alert("ERROR : "+data); |
|
213 } |
|
214 }); |
|
215 } |
|
216 |
|
217 function callbackLdts(json){ |
|
218 /* START PARSING ----------------------- */ |
|
219 /* metas , medias , annotation-types , annotations , lists , tags , views */ |
|
220 /* # fonction avec 1 seul media et 1 seul annotation type code a cleaner */ |
|
221 /* # créer le player */ |
|
222 //$jIRI.each(json.medias, function(i,item) { |
|
223 //}); |
|
224 $jIRI("<div></div>").appendTo("#output"); |
|
225 MyMedia = new Media(json.medias[0].id,json.medias[0].url,json.medias[0]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']); |
|
226 MyMedia.createPlayer(playerLdtWidth,playerLdtHeight); |
|
227 |
|
228 /* # créer lignes */ |
|
229 /*$jIRI.each(json['annotation-types'], function(i,item) { |
|
230 });*/ |
|
231 MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["dc:duration"]); |
|
232 //alert("duration : "+json.medias[0]["dc:duration"]); |
|
233 |
|
234 /* # créer les annotations */ |
|
235 $jIRI.each(json.annotations, function(i,item) { |
|
236 |
|
237 MyLdt.addAnnotation( |
|
238 item.id, |
|
239 item.begin, |
|
240 item.end, |
|
241 item.media, |
|
242 item.content.title, |
|
243 item.content.description, |
|
244 item.content.color); |
|
245 |
|
246 }); |
|
247 $jIRI.each(json.lists, function(i,item) { |
|
248 trace("lists",""); |
|
249 }); |
|
250 $jIRI.each(json.tags, function(i,item) { |
|
251 trace("tags",""); |
|
252 }); |
|
253 $jIRI.each(json.views, function(i,item) { |
|
254 trace("views",""); |
|
255 }); |
|
256 /* END PARSING ----------------------- */ |
|
257 |
|
258 } |
|
259 |
|
260 function trace (msg,value){ |
|
261 $jIRI("<div>"+msg+" : "+value+"</div>").appendTo("#output"); |
|
262 } |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 /* ---------------------------------------------------------------- |
|
268 ---------------------------------------------------------------- |
|
269 INIT player LDT |
|
270 */ |
|
271 |
|
272 function playerLdt (width,height,file,divId){ |
|
273 |
|
274 //$jIRI("#playerLdt").append("<div id=\"div1\">hello</div>"); |
|
275 |
|
276 |
|
277 $jIRI("#"+divId).append("<div id=\"ldtShow\">\n <div id=\"ShowAnnotation\" class=\"demo\" >\n <div id=\"ldtSaTitle\"></div>\n <div id=\"ldtSaDescription\"></div>\n </div> <div id=\"ldtPlaceHolder\">\n <a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player \n </div>\n </div>\n <div id=\"controlerLdt\" class=\"demo\">\n <div class=\"ldtControl1\" >\n <button id=\"ldtCtrlPlay\" onclick=\"player.sendEvent('PLAY')\">Play</button>\n <button id=\"ldtCtrlNext\" onclick=\"player.sendEvent('SEEK', currentPosition+10)\">next</button>\n </div>\n <div id=\"Annotations\" class=\"ui-slider\">\n <div id=\"slider-range-min\"></div>\n </div>\n <div class=\"ldtControl2\">\n <button id=\"ldtCtrlScreen\" onclick=\"player.fullscreen('true')\">Enlarge</button>\n <button id=\"ldtCtrlSound\" onclick=\"player.sendEvent('MUTE')\">Sound</button>\n </div>\n </div>"); |
|
278 loadJson(width,height,file); |
|
279 } |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 /* ---------------------------------------------------------------- |
|
286 ---------------------------------------------------------------- |
|
287 API player */ |
|
288 |
|
289 |
|
290 function APIplayer (){ |
|
291 |
|
292 } |
|
293 |
|
294 |
|
295 |
|
296 /* ---------------------------------------------------------------- |
|
297 ---------------------------------------------------------------- |
|
298 Class Media |
|
299 |
|
300 |
|
301 "http://advene.liris.cnrs.fr/ns/frame_of_reference/ms":"o=0", |
|
302 "id":"kia_closeup", |
|
303 "url":"D:/Thibaut/Outils_techno/IRI-LignesDeTemps/media/video/kia_closeup_BQ.flv", |
|
304 "dc:creator":"tcavalie", |
|
305 "dc:created":"2010-05-04T00:00:00", |
|
306 "dc:contributor":"tcavalie", |
|
307 "dc:modified":"2010-05-04T00:00:00", |
|
308 "dc:creator.contents":"Abbas Kiarostami", |
|
309 "dc:created.contents":"1990", |
|
310 "dc:title":"Close Up is a very very long title", |
|
311 "dc:description":"Analyse de Close Up", |
|
312 "dc:duration":"689266" |
|
313 */ |
|
314 function Media (id,url,duration,title,description){ |
|
315 this.id = id; |
|
316 this.url = url; |
|
317 this.title = title; |
|
318 this.description = description; |
|
319 this.duration = duration; |
|
320 |
|
321 this.lignes = new Array(); |
|
322 this.updatePlayer = updatePlayerMedia; |
|
323 this.getDuration = getMediaDuration; |
|
324 this.createPlayer = createPlayerMedia; |
|
325 |
|
326 trace("Media ID :",id); |
|
327 trace("Media URL :",this.url); |
|
328 trace("- content : color",url); |
|
329 trace("- content : audio",title); |
|
330 } |
|
331 function createPlayerMedia(width,height){ |
|
332 createPlayer(width,height,this.url,this.duration); |
|
333 createInterface(width,height,this.duration); |
|
334 } |
|
335 function updatePlayerMedia(){ |
|
336 |
|
337 } |
|
338 function getMediaDuration(){ |
|
339 return (this.duration); |
|
340 } |
|
341 function getMediaTitle(){ |
|
342 return (this.title); |
|
343 } |
|
344 |
|
345 |
|
346 /* ---------------------------------------------------------------- |
|
347 ---------------------------------------------------------------- |
|
348 Class Ligne (annotationType) |
|
349 |
|
350 "id":"dp_1", |
|
351 "dc:creator":"tcavalie", |
|
352 "dc:created":"2010-04-04T19:09:44", |
|
353 "dc:contributor":"perso", |
|
354 "dc:modified":"15/2/2008", |
|
355 "dc:title":"dqsdkljfh qklsdhf very very very long", |
|
356 "dc:description":"sdfg sdfg sdfg sdfg" |
|
357 */ |
|
358 function Ligne (){ |
|
359 this.id = id; |
|
360 this.title = title; |
|
361 this.description = description; |
|
362 this.annotations = new Array(); |
|
363 this.addAnnotation = addAnnotationligne; |
|
364 this.clickAnnotation= onClickLigneAnnotation; |
|
365 this.checkTime = checkTimeLigne; |
|
366 } |
|
367 |
|
368 function Ligne (id,title,description,duration){ |
|
369 this.id = id; |
|
370 this.title = title; |
|
371 this.description = description; |
|
372 // |
|
373 this.annotations = new Array(); |
|
374 this.addAnnotation = addLigneAnnotation; |
|
375 this.checkTime = checkTimeLigne; |
|
376 this.duration = duration; |
|
377 trace("LIGNE ","créer "); |
|
378 } |
|
379 |
|
380 function addLigneAnnotation(id,begin,end,media,title,description,color){ |
|
381 var myAnnotation = new Annotation(id,begin,end,media,title,description,color,this.duration); |
|
382 this.annotations.push(myAnnotation); |
|
383 trace("LIGNE ","add annotation "); |
|
384 } |
|
385 |
|
386 function onClickLigneAnnotation(id){ |
|
387 player.sendEvent('SEEK', this.start); |
|
388 } |
|
389 |
|
390 function searchLigneAnnotation(id){ |
|
391 /*for (){ |
|
392 }*/ |
|
393 } |
|
394 |
|
395 function listAnnotations(){ |
|
396 |
|
397 } |
|
398 |
|
399 function checkTimeLigne(time){ |
|
400 var annotationTempo; |
|
401 for (var i=0; i < this.annotations.length; ++i){ |
|
402 var annotationTempo = this.annotations[i]; |
|
403 //trace("check... ",time+" = "+annotationTempo.begin+" -- "+annotationTempo.end); |
|
404 //if (time>annotationTempo.begin){ |
|
405 if (time>annotationTempo.begin/1000 && time<annotationTempo.end/1000){ |
|
406 //trace("check ",annotationTempo.begin+" "+annotationTempo.end +" "+annotationTempo.title); |
|
407 $jIRI("#ldtSaTitle").text(annotationTempo.title); |
|
408 $jIRI("#ldtSaDescription").text(annotationTempo.description); |
|
409 break; |
|
410 } |
|
411 } |
|
412 } |
|
413 |
|
414 |
|
415 |
|
416 /* ---------------------------------------------------------------- |
|
417 ---------------------------------------------------------------- |
|
418 CLASSE Annotation |
|
419 |
|
420 |
|
421 "begin":"767", |
|
422 "end":"785", |
|
423 "id":"dp_1_sp_3", |
|
424 "media":"kia_closeup", |
|
425 "content": { |
|
426 "mimetype":"application/x-ldt-structured", |
|
427 "title":"mon titre", |
|
428 "description":"ma description en <b>gras</b> .", |
|
429 "color":"16763904", |
|
430 "audio":{"src":"","mimetype":"audio/mp3","href":""} |
|
431 }, |
|
432 "meta": |
|
433 { |
|
434 "id-ref":"dp_1", |
|
435 "dc:creator":"tcavalie", |
|
436 "dc:created":"2010-04-04T19:09:44", |
|
437 "dc:contributor":"perso", |
|
438 "dc:modified":"9/10/2007" |
|
439 } |
|
440 */ |
|
441 |
|
442 function Annotation (){ |
|
443 this.id = null; |
|
444 this.begin = null; |
|
445 this.end = null; |
|
446 this.media = null; |
|
447 this.description = null; |
|
448 this.title = null; |
|
449 this.color = null; |
|
450 this.onRollOver = onRollOverAnnotation; |
|
451 this.onClick = onClickAnnotation; |
|
452 this.toolTip = rollOverAnnotation; |
|
453 this.draw = drawAnnotation; |
|
454 trace("annotation ","réussi") |
|
455 } |
|
456 |
|
457 function Annotation (id,begin,end,media,title,description,color,duration){ |
|
458 this.id = id; |
|
459 this.begin = begin; |
|
460 this.end = end; |
|
461 this.media = media; |
|
462 this.description = description; |
|
463 this.title = title; |
|
464 this.color = title; |
|
465 this.duration = duration; |
|
466 // |
|
467 this.onRollOver = onRollOverAnnotation; |
|
468 //this.onClick = onClickAnnotation; |
|
469 this.toolTip = tootTipAnnotation; |
|
470 this.draw = drawAnnotation; |
|
471 //this.show = showAnnotationNotice; |
|
472 // draw it |
|
473 this.draw(); |
|
474 |
|
475 // |
|
476 trace("Annotation created : ",id); |
|
477 } |
|
478 |
|
479 function drawAnnotation (){ |
|
480 //alert (this.duration); |
|
481 startPourcent = timeToPourcent(this.begin,this.duration); // temps du média |
|
482 endPourcent = timeToPourcent(this.end,this.duration)-startPourcent; |
|
483 |
|
484 $AnnotationTemplate = "<div title='"+this.title+"' 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;' onclick=\"player.sendEvent('SEEK', '"+Math.round(this.begin/1000)+"');$jIRI('#ShowAnnotation').slideDown().delay(5000).slideUp();\" ></div> "; |
|
485 |
|
486 |
|
487 |
|
488 $toolTipTemplate = "<div class='tooltip'>" |
|
489 +"<div class='title'>"+this.title+"</div>" |
|
490 +"<div class='time'>"+this.begin+" : "+this.end+"</div>" |
|
491 +"<div class='description'>"+this.description+"</div>" |
|
492 +"</div>"; |
|
493 |
|
494 |
|
495 $jIRI("<div>"+$AnnotationTemplate+"</div>").appendTo("#Annotations"); |
|
496 $jIRI("#"+this.id).tooltip({ effect: 'slide'}); |
|
497 |
|
498 trace(" ### ","ADD ANOTATION : "+this.begin+" "+this.end+" "+this.title+" | "+startPourcent+" | "+endPourcent+" | duration = "+this.duration); |
|
499 } |
|
500 |
|
501 function tootTipAnnotation() { |
|
502 // 1 chercher le div correspondant |
|
503 // 2 y mettre les information |
|
504 return this.color + ' ' + this.type + ' apple'; |
|
505 } |
|
506 |
|
507 function onRollOverAnnotation(){ |
|
508 this.tootTip(); |
|
509 } |
|
510 |
|
511 function timeToPourcent(time,timetotal){ |
|
512 return (parseInt(Math.round(time/timetotal*100))); |
|
513 } |
|
514 |
|
515 |
|
516 /* ---------------------------------------------------------------- |
|
517 ---------------------------------------------------------------- |
|
518 Class tracess */ |
|
519 |
|
520 function Tracer (){ |
|
521 |
|
522 } |
|
523 |
|
524 function addTrace(){ |
|
525 |
|
526 } |
|
527 |
|
528 |
|
529 |