|
52
|
1 |
/* |
|
|
2 |
* This file is part of the TraKERS\Front IDILL package. |
|
|
3 |
* |
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
|
5 |
* |
|
|
6 |
* For the full copyright and license information, please view the LICENSE |
|
|
7 |
* file that was distributed with this source code. |
|
|
8 |
*/ |
|
|
9 |
|
|
|
10 |
/* |
|
|
11 |
* Projet : TraKERS |
|
|
12 |
* Module : Front IDILL |
|
|
13 |
* Fichier : Timeline.js |
|
|
14 |
* |
|
|
15 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
16 |
* |
|
|
17 |
* Fonctionnalités : Widget de la timeline du player incorporé dans le Front. |
|
|
18 |
*/ |
|
|
19 |
|
|
31
|
20 |
/* |
|
|
21 |
The Timeline Widget fits right under the video |
|
52
|
22 |
* Est appelé dans les fichiers créant les widgets du metadataplayer. |
|
31
|
23 |
*/ |
|
|
24 |
|
|
|
25 |
IriSP.Widgets.Timeline = function(player, config) { |
|
52
|
26 |
|
|
31
|
27 |
IriSP.Widgets.Widget.call(this, player, config); |
|
52
|
28 |
this.bindPopcorn("timeupdate","onTimeupdate"); |
|
|
29 |
this.bindPopcorn("loadedmetadata","ready"); |
|
|
30 |
this.bindPopcorn("markersready","onMarkersReady"); |
|
|
31 |
this.timelineSelected = false; |
|
|
32 |
this.markerShowTime = 200; |
|
|
33 |
this.markerLastTime = 5000; |
|
|
34 |
this.markerBigShown = false; |
|
|
35 |
this.currentMarkerIdx = -1; |
|
|
36 |
this.previousMarkerIdx = -1; |
|
|
37 |
this.hideTimeout; |
|
|
38 |
this.currentMode = "VIDEO"; |
|
|
39 |
this.paused = false |
|
|
40 |
this.top_epsilon = 0; |
|
|
41 |
this.imgDir = "player/img/"; |
|
|
42 |
this.markersDir = "pictos/small/"; |
|
|
43 |
this.player = player; |
|
|
44 |
this.isCurrentlyInASearchByGesture = false; |
|
|
45 |
this.mouseInteractions = false; |
|
|
46 |
|
|
|
47 |
//Id du marqueur enregistré. |
|
|
48 |
this.currentMarkerId; |
|
|
49 |
|
|
|
50 |
//Gestures et noms par défaut. |
|
61
|
51 |
this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "no-motion", "contact", "up-down"]; |
|
77
|
52 |
this.gesturesText = ["chute", "saut", "rotation", "rotation de groupe", "inclinaison", "port de bras", "levé de genou", "angle droit", "ondulation", "immobilité", "contact", "de haut en bas", "grand-jeté"]; |
|
52
|
53 |
|
|
79
|
54 |
var _this = this; |
|
52
|
55 |
this.annotations = this.source.getAnnotations().filter(function(annotation) |
|
79
|
56 |
{ |
|
|
57 |
return _this.isGesture(annotation, null, _this.gestures); |
|
|
58 |
}); |
|
31
|
59 |
}; |
|
|
60 |
|
|
52
|
61 |
/* |
|
|
62 |
* Constructeur du Widget. |
|
|
63 |
*/ |
|
31
|
64 |
IriSP.Widgets.Timeline.prototype = new IriSP.Widgets.Widget(); |
|
|
65 |
|
|
52
|
66 |
/* |
|
|
67 |
* Indique si l'annotation passée en paramètre référence une gesture utilisée dans ce Front. |
|
|
68 |
*/ |
|
32
|
69 |
IriSP.Widgets.Timeline.prototype.isGesture = function(element, index, array) |
|
|
70 |
{ |
|
52
|
71 |
return ($.inArray(element.annotationType.contents.title, array) > -1); |
|
32
|
72 |
} |
|
|
73 |
|
|
45
|
74 |
/* |
|
|
75 |
* Spécifie si on est en événements souris ou non. |
|
52
|
76 |
* Est appelé dans le fichier : |
|
|
77 |
* mosaic > fonction onMarkersReady. |
|
45
|
78 |
*/ |
|
|
79 |
IriSP.Widgets.Timeline.prototype.setMouseInteractions = function(mouseInteractions) |
|
|
80 |
{ |
|
52
|
81 |
this.mouseInteractions = mouseInteractions; |
|
|
82 |
|
|
|
83 |
if(mouseInteractions) |
|
|
84 |
{ |
|
|
85 |
this.markersDir += 'MI/'; |
|
|
86 |
} |
|
45
|
87 |
} |
|
|
88 |
|
|
46
|
89 |
/* |
|
|
90 |
* Spécifie la langue pour l'affichage des marqueurs. |
|
52
|
91 |
* Est appelé dans le fichier : |
|
|
92 |
* mosaic > fonction onMarkersReady. |
|
46
|
93 |
*/ |
|
|
94 |
IriSP.Widgets.Timeline.prototype.setLang = function(gesturesText) |
|
|
95 |
{ |
|
52
|
96 |
this.gesturesText = gesturesText; |
|
46
|
97 |
} |
|
|
98 |
|
|
52
|
99 |
/* |
|
|
100 |
* Fonction associée à l'événement : les marqueurs sont prêts. |
|
|
101 |
* Est appelé dans le fichier : |
|
|
102 |
* mosaic > fonction onPlayerLoad. |
|
|
103 |
*/ |
|
44
|
104 |
IriSP.Widgets.Timeline.prototype.onMarkersReady = function() {} |
|
|
105 |
|
|
52
|
106 |
/* |
|
|
107 |
* Paramètres par défaut de la timeline. |
|
|
108 |
*/ |
|
31
|
109 |
IriSP.Widgets.Timeline.prototype.defaults = { |
|
44
|
110 |
minimized_height : 114,//44, |
|
|
111 |
maximized_height : 114, |
|
52
|
112 |
middle_height: 10,//4, |
|
|
113 |
timelineBorderLength : 6, |
|
31
|
114 |
minimize_timeout : 1500 // time before minimizing timeline after mouseout |
|
|
115 |
}; |
|
|
116 |
|
|
52
|
117 |
/* |
|
|
118 |
* Fonction appelée pour dessiner la timeline. |
|
|
119 |
*/ |
|
31
|
120 |
IriSP.Widgets.Timeline.prototype.draw = function() { |
|
|
121 |
this.$timeline = IriSP.jQuery('<div>') |
|
|
122 |
.addClass("Ldt-Timeline") |
|
|
123 |
.css(this.calculateTimelineCss(this.minimized_height)); |
|
52
|
124 |
this.$timelineMiddle = IriSP.jQuery('<div>') |
|
|
125 |
.addClass("Ldt-TimelineMiddle") |
|
31
|
126 |
.css(this.calculateTimelineMiddleCss(this.minimized_height, this.middle_height)); |
|
52
|
127 |
|
|
|
128 |
//On l'ajoute au widget. |
|
31
|
129 |
this.$.append(this.$timeline); |
|
|
130 |
this.$.append(this.$timelineMiddle); |
|
|
131 |
var _this = this; |
|
|
132 |
|
|
52
|
133 |
//On définit le slider. |
|
31
|
134 |
this.$timeline.slider({ |
|
|
135 |
range: "min", |
|
|
136 |
value: 0, |
|
|
137 |
min: 0, |
|
|
138 |
max: this.source.getDuration().milliseconds, |
|
|
139 |
slide: function(event, ui) { |
|
52
|
140 |
if(_this.player.popcorn) |
|
|
141 |
{ |
|
|
142 |
_this.player.popcorn.currentTime(Math.floor(ui.value/1000)); |
|
|
143 |
_this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime"); |
|
|
144 |
} |
|
|
145 |
|
|
|
146 |
//On supprime le marqueur précédemment affiché. |
|
|
147 |
if(_this.previousMarkerIdx > -1) |
|
|
148 |
{ |
|
|
149 |
var previousMarker = IriSP.jQuery("#" + _this.annotations[_this.previousMarkerIdx].id.replace(":", "_")); |
|
|
150 |
_this.hideMarkerBig(previousMarker); |
|
|
151 |
} |
|
31
|
152 |
} |
|
|
153 |
}); |
|
52
|
154 |
|
|
31
|
155 |
this.$handle = this.$timeline.find('.ui-slider-handle'); |
|
|
156 |
|
|
|
157 |
this.$handle.css(this.calculateHandleCss(this.minimized_height)); |
|
52
|
158 |
|
|
|
159 |
//On wrapp mouseover et mouse out. |
|
|
160 |
this.$.mouseover(this.functionWrapper("onMouseover")).mouseout(this.functionWrapper("onMouseout")); |
|
|
161 |
//On bind keypress. |
|
|
162 |
IriSP.jQuery('body').keypress(function(evt) {_this.keyPress(evt)}); |
|
31
|
163 |
|
|
|
164 |
this.maximized = false; |
|
|
165 |
this.timeoutId = false; |
|
79
|
166 |
|
|
|
167 |
this.processMarkers(); |
|
31
|
168 |
}; |
|
|
169 |
|
|
|
170 |
/* |
|
|
171 |
* Starts playing the video when it's ready. |
|
|
172 |
*/ |
|
|
173 |
IriSP.Widgets.Timeline.prototype.ready = function() { |
|
52
|
174 |
this.player.popcorn.play(); |
|
|
175 |
this.player.popcorn.mute(); |
|
79
|
176 |
// this.processMarkers(); |
|
31
|
177 |
} |
|
|
178 |
|
|
|
179 |
/* |
|
52
|
180 |
* Met à l'échelle une valeur de [A, B] vers [C, D]. |
|
|
181 |
* Est appelé dans les fichiers : |
|
|
182 |
* pointers > fonction pointersTimelineSelection. |
|
|
183 |
* search > fonction searchFilter. |
|
|
184 |
* Timeline > fonctions processMarkers, onTimeupdate et timeDisplayUpdater. |
|
31
|
185 |
*/ |
|
|
186 |
IriSP.Widgets.Timeline.prototype.scaleIntervals = function(A, B, C, D, val) { |
|
61
|
187 |
if(A == B) |
|
79
|
188 |
{ |
|
|
189 |
return (D - C) / 2; |
|
|
190 |
} |
|
|
191 |
else |
|
|
192 |
{ |
|
|
193 |
return (D - C) * (val - A) / (B - A) + C; |
|
|
194 |
} |
|
31
|
195 |
} |
|
|
196 |
|
|
|
197 |
/* |
|
52
|
198 |
* On calcule les marqueurs. |
|
|
199 |
* Est appelé dans le fichier : |
|
|
200 |
* Timeline > fonction ready. |
|
31
|
201 |
*/ |
|
|
202 |
IriSP.Widgets.Timeline.prototype.processMarkers = function() { |
|
52
|
203 |
var _this = this; |
|
|
204 |
var markers = ""; |
|
|
205 |
//On calcule la position en Y de la timeline. |
|
|
206 |
var timelineMiddleTop = this.$timelineMiddle.position().top; |
|
|
207 |
|
|
79
|
208 |
var TLHeight = this.$timeline.height()/2; |
|
|
209 |
|
|
52
|
210 |
//Pour toutes les annotations, on crée les marqueurs. |
|
|
211 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
212 |
{ |
|
|
213 |
markers += "<div class='Ldt-Marker' id='" + this.annotations[i].id.replace(":", "_") + "'></div>"; |
|
|
214 |
} |
|
|
215 |
//On les ajoute. |
|
|
216 |
this.$.append(markers); |
|
|
217 |
var markerHeight = IriSP.jQuery(".Ldt-Marker").height(); |
|
|
218 |
IriSP.jQuery(".Ldt-Marker").css("z-align", "150"); |
|
|
219 |
|
|
|
220 |
//Pour toutes les annotations. |
|
|
221 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
222 |
{ |
|
|
223 |
//On les place sur la timeline. |
|
|
224 |
IriSP.jQuery("#" + this.annotations[i].id.replace(":", "_")).css( |
|
|
225 |
{ |
|
|
226 |
top: timelineMiddleTop + "px", |
|
|
227 |
left: Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), this.annotations[i].begin/1000) + this.$timeline.position().left) + "px", |
|
79
|
228 |
"margin-top": (-TLHeight - markerHeight/2) - this.top_epsilon + "px" |
|
52
|
229 |
}); |
|
|
230 |
} |
|
|
231 |
|
|
|
232 |
//On lance l'événement pour dire à popcorn que les marqueurs sont utilisables. |
|
|
233 |
this.player.popcorn.trigger("markersready"); |
|
44
|
234 |
} |
|
|
235 |
|
|
|
236 |
/* |
|
52
|
237 |
* Fonction de recherche par gestures. |
|
|
238 |
* Est appelé dans les fichiers : |
|
|
239 |
* mosaic > fonctions onMouseUp, manageControlEvents et onMarkersReady. |
|
|
240 |
* curvesDetector > fonction updateDists. |
|
44
|
241 |
*/ |
|
|
242 |
IriSP.Widgets.Timeline.prototype.searchByGesture = function(typeName) |
|
|
243 |
{ |
|
52
|
244 |
//Si le type existe. |
|
|
245 |
if(typeName != '' || typeName != undefined) |
|
|
246 |
{ |
|
|
247 |
if(_.include(this.gestures, typeName)) |
|
|
248 |
{ |
|
|
249 |
//On entre en mode recherche et on affiche les marqueurs sélectionnés. |
|
|
250 |
this.currentMode = "SEARCH"; |
|
|
251 |
this.hideMarkersSearch(typeName); |
|
|
252 |
this.isCurrentlyInASearchByGesture = true; |
|
|
253 |
} |
|
|
254 |
} |
|
44
|
255 |
} |
|
|
256 |
|
|
|
257 |
/* |
|
|
258 |
* Fonction de suppression de recherche par gesures. |
|
52
|
259 |
* Est appelé dans le fichier : |
|
|
260 |
* pointers > checkIfPointerIsOnSearchNotification et removeSearchNotificationIfOnIt. |
|
44
|
261 |
*/ |
|
|
262 |
IriSP.Widgets.Timeline.prototype.removeSearchByGesture = function() |
|
|
263 |
{ |
|
52
|
264 |
this.hideMarkersSearch(); |
|
|
265 |
this.isCurrentlyInASearchByGesture = false; |
|
|
266 |
} |
|
|
267 |
|
|
|
268 |
/* |
|
|
269 |
* Place le curseur sur la timeline en fonction de la touche pressée. |
|
|
270 |
* Est appelé dans le fichier : |
|
|
271 |
*/ |
|
|
272 |
IriSP.Widgets.Timeline.prototype.keyPress = function(e) { |
|
|
273 |
var key = this.whichKey(e.which); |
|
|
274 |
var time = 0; |
|
|
275 |
|
|
|
276 |
//Entre 0 et 10, on met à jour la position du curseur dans la video. |
|
|
277 |
if(key > -1 && key < 11) |
|
|
278 |
{ |
|
|
279 |
time = this.source.getDuration().getSeconds()/10*key; |
|
|
280 |
this.$timeline.slider("value",time); |
|
|
281 |
this.player.popcorn.currentTime(time); |
|
|
282 |
|
|
|
283 |
//On supprime le marqueur précédemment affiché. |
|
|
284 |
if(this.previousMarkerIdx > -1) |
|
|
285 |
{ |
|
|
286 |
var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_")); |
|
|
287 |
this.hideMarkerBig(previousMarker); |
|
|
288 |
} |
|
|
289 |
} |
|
|
290 |
|
|
|
291 |
//p ou P pour mettre en pause. |
|
|
292 |
if(key == 21) |
|
|
293 |
{ |
|
|
294 |
if(!this.paused) |
|
|
295 |
{ |
|
|
296 |
this.paused = true; |
|
|
297 |
this.player.popcorn.pause(); |
|
|
298 |
} |
|
|
299 |
else |
|
|
300 |
{ |
|
|
301 |
this.paused = false; |
|
|
302 |
this.player.popcorn.play(); |
|
|
303 |
} |
|
|
304 |
} |
|
31
|
305 |
} |
|
|
306 |
|
|
|
307 |
/* |
|
52
|
308 |
* Donne une clé correspondante à une touche donnée. |
|
|
309 |
* Est appelé dans le fichier : |
|
|
310 |
* Timeline > fonction keyPress. |
|
|
311 |
*/ |
|
|
312 |
IriSP.Widgets.Timeline.prototype.whichKey = function(code) { |
|
|
313 |
var key; |
|
|
314 |
|
|
|
315 |
if(code > 47 && code < 58) |
|
|
316 |
{ |
|
|
317 |
return (code - 48); |
|
|
318 |
} |
|
|
319 |
|
|
|
320 |
if(code == 115 || code == 83) |
|
|
321 |
{ |
|
|
322 |
return 11; |
|
|
323 |
} |
|
|
324 |
|
|
|
325 |
//p ou P pour mettre la vidéo en pause. |
|
|
326 |
if(code == 112 || code == 80) |
|
|
327 |
{ |
|
|
328 |
return 21; |
|
|
329 |
} |
|
|
330 |
|
|
|
331 |
switch(code) |
|
|
332 |
{ |
|
|
333 |
case 224: |
|
|
334 |
key = 0; |
|
|
335 |
break; |
|
|
336 |
case 38: |
|
|
337 |
key = 1; |
|
|
338 |
break; |
|
|
339 |
case 233: |
|
|
340 |
key = 2; |
|
|
341 |
break; |
|
|
342 |
case 34: |
|
|
343 |
key = 3; |
|
|
344 |
break; |
|
|
345 |
case 39: |
|
|
346 |
key = 4; |
|
|
347 |
break; |
|
|
348 |
case 40: |
|
|
349 |
key = 5; |
|
|
350 |
break; |
|
|
351 |
case 45: |
|
|
352 |
key = 6; |
|
|
353 |
break; |
|
|
354 |
case 232: |
|
|
355 |
key = 7; |
|
|
356 |
break; |
|
|
357 |
case 95: |
|
|
358 |
key = 8; |
|
|
359 |
break; |
|
|
360 |
case 231: |
|
|
361 |
key = 9; |
|
|
362 |
break; |
|
|
363 |
default: |
|
|
364 |
key = -1; |
|
|
365 |
} |
|
|
366 |
|
|
|
367 |
return key; |
|
|
368 |
} |
|
|
369 |
|
|
|
370 |
/* |
|
|
371 |
* Fonction de sélection de la timeline. |
|
|
372 |
* Est appelé dans le fichier : |
|
|
373 |
* pointers > fonction pointersTimelineSelection. |
|
31
|
374 |
*/ |
|
52
|
375 |
IriSP.Widgets.Timeline.prototype.selectTimeline = function() { |
|
|
376 |
//On crée les bordures. |
|
|
377 |
this.timelineSelected = true; |
|
|
378 |
this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>"; |
|
|
379 |
this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>"; |
|
|
380 |
this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>"; |
|
|
381 |
this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>"; |
|
|
382 |
//Les flèches verticales aussi. |
|
|
383 |
this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>"; |
|
|
384 |
this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>"; |
|
|
385 |
//On les ajoute. |
|
|
386 |
this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown); |
|
|
387 |
//On calcule la position en Y de la timeline. |
|
|
388 |
var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height(); |
|
|
389 |
//On met les styles à jour. |
|
|
390 |
IriSP.jQuery("#TL_BorderUp").css( |
|
|
391 |
{ |
|
|
392 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
393 |
left: this.$timeline.position().left, |
|
|
394 |
width: this.$timeline.width(), |
|
|
395 |
height: this.timelineBorderLength |
|
|
396 |
}); |
|
|
397 |
IriSP.jQuery("#TL_BorderDown").css( |
|
|
398 |
{ |
|
|
399 |
"margin-top": -this.timelineBorderLength - 2 - this.top_epsilon, |
|
|
400 |
left: this.$timeline.position().left, |
|
|
401 |
width: this.$timeline.width(), |
|
|
402 |
height: this.timelineBorderLength |
|
|
403 |
}); |
|
|
404 |
IriSP.jQuery("#TL_BorderLeft").css( |
|
|
405 |
{ |
|
|
406 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
407 |
left: this.$timeline.position().left, |
|
|
408 |
width: this.timelineBorderLength, |
|
|
409 |
height: this.$timeline.height() |
|
|
410 |
}); |
|
|
411 |
IriSP.jQuery("#TL_BorderRight").css( |
|
|
412 |
{ |
|
|
413 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
414 |
left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2, |
|
|
415 |
width: this.timelineBorderLength, |
|
|
416 |
height: this.$timeline.height() |
|
|
417 |
}); |
|
|
418 |
|
|
|
419 |
IriSP.jQuery("#TL_ArrowUp").css( |
|
|
420 |
{ |
|
|
421 |
"background-image": "url(" + this.imgDir + "arrow_up.png)", |
|
|
422 |
"margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon, |
|
|
423 |
left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2, |
|
|
424 |
}); |
|
|
425 |
IriSP.jQuery("#TL_ArrowDown").css( |
|
|
426 |
{ |
|
|
427 |
"background-image": "url(" + this.imgDir + "arrow_down.png)", |
|
|
428 |
"margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon, |
|
|
429 |
left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2, |
|
|
430 |
}); |
|
|
431 |
|
|
|
432 |
IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)"); |
|
|
433 |
} |
|
|
434 |
|
|
|
435 |
/* |
|
|
436 |
* Déselectionne la timeline. |
|
|
437 |
* Est appelé dans le fichier : |
|
|
438 |
* playerControl > fonction exitTimeline. |
|
|
439 |
*/ |
|
|
440 |
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() { |
|
|
441 |
//On supprime les éléments qui faisaient que la timeline était sélectionnée. |
|
|
442 |
this.timelineSelected = false; |
|
|
443 |
IriSP.jQuery(".TL_Borders").remove(); |
|
|
444 |
IriSP.jQuery(".TL_Arrows").remove(); |
|
|
445 |
IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)"); |
|
31
|
446 |
} |
|
|
447 |
|
|
|
448 |
/* |
|
52
|
449 |
* Se met à jour durant la lecture d'une video. |
|
|
450 |
* Est appelé dans le fichier : |
|
|
451 |
* Timeline |
|
31
|
452 |
*/ |
|
52
|
453 |
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() { |
|
|
454 |
//On récupère la position du curseur en secondes. |
|
|
455 |
var _time = this.player.popcorn.currentTime(); |
|
|
456 |
//Position des flèches au cas où la timeline serait sélectionnée. |
|
|
457 |
var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) - IriSP.jQuery("#TL_ArrowUp").width()/2 + "px"; |
|
|
458 |
//On met à jour la position du slider en ms. |
|
|
459 |
this.$timeline.slider("value",_time*1000); |
|
|
460 |
//On affiche les flèches si la timeline est sélectionnée. |
|
|
461 |
IriSP.jQuery(".TL_Arrows").css("display", "block"); |
|
|
462 |
IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft); |
|
|
463 |
IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft); |
|
|
464 |
|
|
|
465 |
//Si on a une distance de 500 ms à un marqueur, on l'affiche. |
|
|
466 |
var nearestMarkerIdx = 0; |
|
|
467 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
468 |
{ |
|
|
469 |
//S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms). |
|
|
470 |
if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250) |
|
|
471 |
{ |
|
|
472 |
//On sélectionne le plus proche marqueur (dans les cas où il en existe plusieurs dans l'intervalle des 1s) ou bien le premier marqueur. |
|
|
473 |
if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) < Math.abs(_time*1000 - this.annotations[nearestMarkerIdx].begin.milliseconds) || i == nearestMarkerIdx) |
|
|
474 |
{ |
|
|
475 |
//Si le prochain marqueur se situe après le curseur de lecture, on passe donc au marqueur le plus proche. |
|
|
476 |
if(_time*1000 < this.annotations[i].begin.milliseconds) |
|
|
477 |
{ |
|
|
478 |
nearestMarkerIdx = i; |
|
|
479 |
//S'il y a un changement de marqueur (marqueur actuel différent du précédent). |
|
|
480 |
if(nearestMarkerIdx != this.previousMarkerIdx) |
|
|
481 |
{ |
|
|
482 |
var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_")); |
|
79
|
483 |
|
|
52
|
484 |
//S'il existe un marqueur précédent, on le cache. |
|
|
485 |
if(this.previousMarkerIdx > -1) |
|
|
486 |
{ |
|
|
487 |
var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_")); |
|
|
488 |
this.hideMarkerBig(previousMarker); |
|
|
489 |
} |
|
|
490 |
|
|
|
491 |
this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title); |
|
|
492 |
//Mise à jour du marqueur précédent s'il y a un changement. |
|
|
493 |
this.previousMarkerIdx = nearestMarkerIdx; |
|
|
494 |
} |
|
|
495 |
} |
|
|
496 |
} |
|
|
497 |
this.currentMarkerIdx = nearestMarkerIdx; |
|
|
498 |
} |
|
|
499 |
} |
|
31
|
500 |
} |
|
|
501 |
|
|
52
|
502 |
/* |
|
|
503 |
* Met à jour l'affichage régulièrement. |
|
|
504 |
* Est appelé dans le fichier : |
|
|
505 |
* Timeline |
|
|
506 |
*/ |
|
|
507 |
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() { |
|
|
508 |
//On récupère la position du curseur en secondes. |
|
|
509 |
var _time = this.player.popcorn.currentTime(); |
|
|
510 |
//Position des flèches au cas où la timeline serait sélectionnée. |
|
|
511 |
var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) - |
|
|
512 |
this.$timeline.slider("value",_time*1000); |
|
|
513 |
//On affiche les flèches si la timeline est sélectionnée. |
|
|
514 |
IriSP.jQuery(".TL_Arrows").css("display", "block"); |
|
|
515 |
IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft); |
|
|
516 |
IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft); |
|
31
|
517 |
} |
|
|
518 |
|
|
52
|
519 |
/* |
|
|
520 |
* Fonction appelée quand la souris est au dessus de la timeline. |
|
|
521 |
*/ |
|
44
|
522 |
IriSP.Widgets.Timeline.prototype.onMouseover = function() {} |
|
31
|
523 |
|
|
52
|
524 |
/* |
|
|
525 |
* Fonction appelée quand la souris est hors de la timeline. |
|
|
526 |
*/ |
|
44
|
527 |
IriSP.Widgets.Timeline.prototype.onMouseout = function() {} |
|
31
|
528 |
|
|
52
|
529 |
/* |
|
|
530 |
* Fonction appelée pour modifier la hauteur de la timeline. |
|
|
531 |
*/ |
|
44
|
532 |
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {} |
|
31
|
533 |
|
|
52
|
534 |
/* |
|
|
535 |
* Calcule le css de la timeline. |
|
|
536 |
* Est appelé dans le fichier : |
|
|
537 |
* Timeline > fonction draw. |
|
|
538 |
*/ |
|
31
|
539 |
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) { |
|
52
|
540 |
//Longueur du player. |
|
|
541 |
var middleWidth = this.player.config.gui.width; |
|
79
|
542 |
var TLHeight = _size; |
|
|
543 |
|
|
52
|
544 |
//On met à jour la marge, les coordonnées et positions de la timeline. |
|
31
|
545 |
return { |
|
52
|
546 |
position: "absolute", |
|
|
547 |
top: "0px", |
|
|
548 |
left: "0px", |
|
|
549 |
width: middleWidth + "px", |
|
79
|
550 |
height: TLHeight + "px", |
|
31
|
551 |
"margin-top": (-this.minimized_height - this.top_epsilon) + "px", |
|
52
|
552 |
"z-align": "50" |
|
31
|
553 |
}; |
|
|
554 |
} |
|
|
555 |
|
|
52
|
556 |
/* |
|
|
557 |
* Calcule le css de la barre grise de milieu de la timeline. |
|
|
558 |
* Est appelé dans le fichier : |
|
|
559 |
* Timeline > fonction draw. |
|
|
560 |
*/ |
|
31
|
561 |
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) { |
|
52
|
562 |
//Longueur du player. |
|
|
563 |
var middleWidth = this.player.config.gui.width; |
|
|
564 |
//On met à jour la marge, les coordonnées et positions de la barre grise de milieu de la timeline. |
|
31
|
565 |
return { |
|
52
|
566 |
position: "absolute", |
|
|
567 |
top: "0px", |
|
|
568 |
left: "0px", |
|
|
569 |
width: middleWidth + "px", |
|
31
|
570 |
height: _middleSize + "px", |
|
|
571 |
"margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px", |
|
52
|
572 |
"z-align": "100" |
|
31
|
573 |
}; |
|
|
574 |
} |
|
|
575 |
|
|
52
|
576 |
/* |
|
|
577 |
* Calcule le css de la portion de la timeline qui a déjà été lue. |
|
|
578 |
* Est appelé dans le fichier : |
|
|
579 |
* Timeline > fonction draw. |
|
|
580 |
*/ |
|
31
|
581 |
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) { |
|
|
582 |
return { |
|
52
|
583 |
position: "absolute", |
|
|
584 |
top: "0px", |
|
|
585 |
left: "0px", |
|
31
|
586 |
height: (2 + _size) + "px", |
|
|
587 |
width: (2 + _size) + "px", |
|
|
588 |
"margin-left": -Math.ceil(2 + _size / 2) + "px", |
|
52
|
589 |
"z-align": "60" |
|
31
|
590 |
} |
|
|
591 |
} |
|
|
592 |
|
|
52
|
593 |
/* |
|
|
594 |
* Affiche les marqueurs lorsqu'ils sont affichés au passage du curseur. |
|
|
595 |
* Est appelé dans le fichier : |
|
|
596 |
* Timeline > fonction onTimeupdate. |
|
|
597 |
*/ |
|
31
|
598 |
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) { |
|
52
|
599 |
//Si le marqueur est déjà affiché, on part. |
|
|
600 |
if(this.markerBigShown) |
|
|
601 |
{ |
|
|
602 |
return; |
|
|
603 |
} |
|
|
604 |
|
|
|
605 |
//On annule le masquage du pointeur. |
|
|
606 |
clearTimeout(this.hideTimeout); |
|
|
607 |
|
|
|
608 |
var _this = this; |
|
|
609 |
//On met à jour la position du marqueur. |
|
|
610 |
var markerTop, markerLeft; |
|
|
611 |
|
|
|
612 |
if(marker.position() == null) |
|
|
613 |
{ |
|
|
614 |
markerTop = 0; |
|
|
615 |
markerLeft = 0; |
|
|
616 |
} |
|
|
617 |
else |
|
|
618 |
{ |
|
|
619 |
markerTop = marker.position().top; |
|
|
620 |
markerLeft = marker.position().left; |
|
|
621 |
} |
|
|
622 |
//Ses dimensions aussi. |
|
|
623 |
var markerWidth = marker.width(), markerHeight = marker.height(); |
|
|
624 |
//On spécifie qu'il est affiché. |
|
|
625 |
this.markerBigShown = true; |
|
|
626 |
//On le crée. |
|
|
627 |
var markerBig = "<div class='TL_MarkersBig' id='MB_Text'>" + this.gesturesText[IriSP.jQuery.inArray(type, this.gestures)] + "<div class='TL_MarkersBig' id='MB_Spike'></div></div><div class='TL_MarkersBig' id='MB_Pic'></div>"; |
|
|
628 |
//On l'ajoute. |
|
|
629 |
this.$.append(markerBig); |
|
|
630 |
//On forme ses éléments. |
|
|
631 |
var markerBigText = IriSP.jQuery("#MB_Text"); |
|
|
632 |
var markerBigSpike = IriSP.jQuery("#MB_Spike"); |
|
|
633 |
var markerBigPic = IriSP.jQuery("#MB_Pic"); |
|
|
634 |
//On spécifie leurs coordonnées et dimensions. |
|
|
635 |
var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight(); |
|
|
636 |
var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height(); |
|
|
637 |
var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height(); |
|
79
|
638 |
var markerBigPicTop = +parseInt(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2); |
|
|
639 |
var markerBigTextTop = (parseInt(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2); |
|
52
|
640 |
var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2); |
|
|
641 |
//On va chercher les images correspondantes. |
|
|
642 |
marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)"); |
|
|
643 |
//On met à jour leur apparence. |
|
79
|
644 |
|
|
52
|
645 |
IriSP.jQuery("#MB_Text").css( |
|
|
646 |
{ |
|
|
647 |
top: markerBigTextTop, |
|
|
648 |
left: markerBigTextLeft |
|
|
649 |
}); |
|
|
650 |
IriSP.jQuery("#MB_Spike").css( |
|
|
651 |
{ |
|
|
652 |
left: markerBigSpikeLeft |
|
|
653 |
}); |
|
|
654 |
IriSP.jQuery("#MB_Pic").css( |
|
|
655 |
{ |
|
|
656 |
"background-image": "url(" + this.markersDir + type + ".png)", |
|
|
657 |
top: markerBigPicTop, |
|
|
658 |
left: markerBigPicLeft, |
|
|
659 |
"z-index": "400" |
|
|
660 |
}); |
|
|
661 |
//On l'affiche. |
|
|
662 |
IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1"); |
|
|
663 |
|
|
|
664 |
//On rajoute un timeout pour supprimer le marqueur après un certain temps. |
|
|
665 |
this.hideTimeout = setTimeout(function() |
|
|
666 |
{ |
|
|
667 |
_this.hideMarkerBig(marker); |
|
|
668 |
}, this.markerLastTime); |
|
31
|
669 |
} |
|
|
670 |
|
|
52
|
671 |
/* |
|
|
672 |
* Cache un marqueur. |
|
|
673 |
* Est appelé dans le fichier : |
|
|
674 |
* Timeline > fonctions draw, keyPress, onTimeupdate et showMarkerBig. |
|
|
675 |
*/ |
|
31
|
676 |
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) { |
|
52
|
677 |
//S'il n'est pas affiché, on part. |
|
|
678 |
if(!this.markerBigShown) |
|
|
679 |
{ |
|
|
680 |
return; |
|
|
681 |
} |
|
|
682 |
|
|
|
683 |
//On lui remet son apparence initiale. |
|
|
684 |
this.currentMarker = -1; |
|
|
685 |
this.markerBigShown = false; |
|
|
686 |
marker.css("background-image", "url(" + this.imgDir + "marker.png)"); |
|
|
687 |
//On efface ce qui était affiché du marqueur. |
|
|
688 |
IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove(); |
|
31
|
689 |
} |
|
|
690 |
|
|
|
691 |
/* |
|
|
692 |
* Affiche le bas des marqueurs correspondants à la recherche. |
|
52
|
693 |
* Est appelé dans le fichier : |
|
|
694 |
* Timeline > fonction hideMarkersSearch. |
|
31
|
695 |
*/ |
|
|
696 |
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) { |
|
52
|
697 |
//Si on est en mode SEARCH. |
|
|
698 |
if(this.currentMode != "SEARCH") |
|
|
699 |
{ |
|
|
700 |
return; |
|
|
701 |
} |
|
|
702 |
|
|
|
703 |
var _this = this; |
|
|
704 |
|
|
|
705 |
//On récupère les annotations. |
|
|
706 |
var markersSearch = "", markersPicSearch = ""; |
|
|
707 |
//Pour chaque annotation, on ajoute un double. |
|
|
708 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
709 |
{ |
|
|
710 |
//Si elle correspond à la recherche. |
|
|
711 |
if(this.annotations[i].annotationType.contents.title == type) |
|
|
712 |
{ |
|
|
713 |
//On récupère le marqueur associé à l'annotation. |
|
|
714 |
var markerId = this.annotations[i].id.replace(":", "_"); |
|
|
715 |
|
|
|
716 |
markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>"; |
|
|
717 |
markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>"; |
|
|
718 |
} |
|
|
719 |
} |
|
|
720 |
|
|
|
721 |
this.$.append(markersSearch + markersPicSearch); |
|
|
722 |
|
|
|
723 |
//On place chaque double. |
|
|
724 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
725 |
{ |
|
|
726 |
//Si elle correspond à la recherche. |
|
|
727 |
if(this.annotations[i].annotationType.contents.title == type) |
|
|
728 |
{ |
|
|
729 |
//On calcule les coordonnées et dimensions du marqueur. |
|
|
730 |
var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId); |
|
|
731 |
var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height(); |
|
79
|
732 |
var markerBigPicWidth = parseInt(IriSP.jQuery(".search_MBPic").css("width")), markerBigPicHeight = parseInt(IriSP.jQuery(".search_MBPic").css("height")), markerBigPicTop = +parseInt(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2); |
|
52
|
733 |
//On calcule son apparence et on le fait apparaître. |
|
|
734 |
IriSP.jQuery("#search_Pic_" + markerId).css( |
|
|
735 |
{ |
|
|
736 |
position: "absolute", |
|
|
737 |
"background-image": "url(" + this.markersDir + type + ".png)", |
|
|
738 |
top: markerBigPicTop, |
|
|
739 |
left: markerBigPicLeft, |
|
|
740 |
"z-index": "300" |
|
|
741 |
}).fadeTo(this.markerShowTime, "1"); |
|
|
742 |
|
|
|
743 |
IriSP.jQuery("#search_Marker_" + markerId).css( |
|
|
744 |
{ |
|
|
745 |
position: "absolute", |
|
|
746 |
top: _this.$timelineMiddle.position().top - _this.top_epsilon, |
|
|
747 |
"margin-top": (-_this.$timeline.height()/2 - markerHeight/2), |
|
|
748 |
"background-image": "url(" + this.imgDir + "selected_marker.png)", |
|
|
749 |
left: markerLeft, |
|
|
750 |
"z-index": "300" |
|
|
751 |
}).fadeTo(this.markerShowTime, "1"); |
|
|
752 |
} |
|
|
753 |
} |
|
31
|
754 |
} |
|
|
755 |
|
|
|
756 |
/* |
|
|
757 |
* Enlever une recherche faite précédemment. |
|
52
|
758 |
* Est appelé dans le fichier : |
|
|
759 |
* Timeline > fonctions searchByGesture et removeSearchByGesture. |
|
31
|
760 |
*/ |
|
|
761 |
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) { |
|
52
|
762 |
//Si on est en mode SEARCH. |
|
|
763 |
if(this.currentMode != "SEARCH") |
|
|
764 |
{ |
|
|
765 |
return; |
|
|
766 |
} |
|
|
767 |
|
|
|
768 |
var _this = this; |
|
|
769 |
|
|
|
770 |
//On efface tous les marqueurs affichés. |
|
|
771 |
IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function() |
|
|
772 |
{ |
|
|
773 |
IriSP.jQuery("div").remove(".search_MBPic"); |
|
|
774 |
}); |
|
|
775 |
IriSP.jQuery(".search_Marker").fadeOut(this.markerShowTime, function() |
|
|
776 |
{ |
|
|
777 |
IriSP.jQuery("div").remove(".search_Marker"); |
|
|
778 |
|
|
|
779 |
//Si le type est définit, c'est qu'on souhaite remplacer cette recherche par une autre. |
|
|
780 |
if(type == undefined) |
|
|
781 |
{ |
|
|
782 |
_this.currentMode = "VIDEO"; |
|
|
783 |
} |
|
|
784 |
else |
|
|
785 |
{ |
|
|
786 |
_this.showMarkersSearchByType(type); |
|
|
787 |
return; |
|
|
788 |
} |
|
|
789 |
}); |
|
|
790 |
|
|
|
791 |
//Si à la base il n'y avait pas de marqueurs affichés, on crée une nouvelle recherche si le type est définit. |
|
|
792 |
if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined) |
|
|
793 |
{ |
|
|
794 |
this.showMarkersSearchByType(type); |
|
|
795 |
} |
|
33
|
796 |
} |
|
|
797 |
|
|
52
|
798 |
/* |
|
|
799 |
* Libère le player. |
|
|
800 |
* Est appelé dans les fichiers : |
|
|
801 |
* neighbours > fonction moveToNeighbour. |
|
|
802 |
* zoomInteractions > fonction unzoom. |
|
|
803 |
*/ |
|
33
|
804 |
IriSP.Widgets.Timeline.prototype.freePlayer = function() |
|
|
805 |
{ |
|
52
|
806 |
IriSP.jQuery('body').unbind('keypress'); |
|
|
807 |
IriSP.jQuery('.notifications').remove(); |
|
33
|
808 |
} |
|
|
809 |
|
|
|
810 |
/* |
|
44
|
811 |
* Va au marqueur suivant/précédant lors d'un swipe right/left dans une lecture simple. |
|
|
812 |
* Prend comme argument le fait qu'il s'agisse d'un swipe left ou non (en prenant en condition toujours vraie |
|
|
813 |
* que la fonction est appelée si et seulement si il y a swipe et que l'utilisateur ne tente pas d'aller vers un voisin. |
|
52
|
814 |
* Est appelé dans le fichier : |
|
|
815 |
* mosaic > fonction manageControlEvents. |
|
44
|
816 |
*/ |
|
|
817 |
IriSP.Widgets.Timeline.prototype.switchToMarker = function(isSwipeLeft, searchedGesture) |
|
|
818 |
{ |
|
61
|
819 |
//On prend le temps actuel du curseur en ms. |
|
52
|
820 |
var currentCursorPosition = this.player.popcorn.currentTime() * 1000; |
|
|
821 |
//Position visée. |
|
|
822 |
var targetCursorPosition = currentCursorPosition; |
|
|
823 |
//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right. |
|
|
824 |
var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0; |
|
79
|
825 |
|
|
|
826 |
//Condition de sélection du marqueur selon le type de swipe. |
|
|
827 |
var swipeCondition; |
|
|
828 |
|
|
52
|
829 |
//Si il y a au moins 1 annotation. |
|
|
830 |
if(this.annotations && this.annotations.length > 0) |
|
|
831 |
{ |
|
79
|
832 |
//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position. |
|
|
833 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
834 |
{ |
|
|
835 |
swipeCondition = (isSwipeLeft ? (currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) : (currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin))); |
|
|
836 |
|
|
|
837 |
if(swipeCondition) |
|
|
838 |
{ |
|
|
839 |
//Si on recherche une gesture. |
|
|
840 |
if(searchedGesture != '') |
|
|
841 |
{ |
|
|
842 |
//Si l'annotation actuelle ne correspond pas à la gesture recherchée, on passe. |
|
|
843 |
if(this.annotations[i].annotationType.contents.title != searchedGesture) |
|
|
844 |
{ |
|
|
845 |
continue; |
|
|
846 |
} |
|
|
847 |
} |
|
|
848 |
|
|
|
849 |
//On calcule la plus petite distance entre le marqueur marqueur actuel et les autres. |
|
|
850 |
minDistance = (currentCursorPosition - this.annotations[i].begin); |
|
|
851 |
minIdx = i; |
|
|
852 |
} |
|
|
853 |
} |
|
52
|
854 |
|
|
|
855 |
//On obtient la position du plus proche marqueur. |
|
|
856 |
targetCursorPosition = this.annotations[minIdx].begin; |
|
|
857 |
|
|
|
858 |
//Si le marqueur est situé minimum à 1s du début de la video, on place la position cible à 1s avant celle du marqueur recherché. |
|
|
859 |
if(this.annotations[minIdx].begin > 1000) |
|
|
860 |
{ |
|
|
861 |
targetCursorPosition -= 1000; |
|
|
862 |
} |
|
|
863 |
} |
|
|
864 |
|
|
|
865 |
//On place le marqueur au niveau de la position cible. |
|
|
866 |
this.player.popcorn.currentTime(targetCursorPosition / 1000); |
|
|
867 |
} |
|
|
868 |
|
|
|
869 |
/* |
|
|
870 |
* Indique s'il y a des marqueurs devant le curseur (pour une recherche). |
|
|
871 |
* Est appelé dans le fichier : |
|
|
872 |
* mosaic > fonction manageControlEvents. |
|
|
873 |
*/ |
|
|
874 |
IriSP.Widgets.Timeline.prototype.isAMarkerAhead = function(searchedGesture) |
|
|
875 |
{ |
|
|
876 |
if(searchedGesture == '') |
|
|
877 |
{ |
|
|
878 |
return true; |
|
|
879 |
} |
|
|
880 |
|
|
|
881 |
//On prend le temps actuel du curseur en ms. |
|
|
882 |
var currentCursorPosition = this.player.popcorn.currentTime() * 1000; |
|
|
883 |
//Position visée. |
|
|
884 |
var targetCursorPosition = currentCursorPosition; |
|
|
885 |
//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right. |
|
|
886 |
var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0; |
|
|
887 |
|
|
|
888 |
//Si il y a au moins 1 annotation. |
|
|
889 |
if(this.annotations && this.annotations.length > 0) |
|
|
890 |
{ |
|
|
891 |
//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position. |
|
|
892 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
893 |
{ |
|
|
894 |
if(this.annotations[i].annotationType.contents.title == searchedGesture && currentCursorPosition < this.annotations[i].begin) |
|
|
895 |
{ |
|
|
896 |
return true; |
|
|
897 |
} |
|
|
898 |
} |
|
|
899 |
} |
|
|
900 |
|
|
|
901 |
//Si elle n'a pas été trouvée on renvoie faux. |
|
|
902 |
return false; |
|
44
|
903 |
} |
|
|
904 |
|
|
|
905 |
/* |
|
|
906 |
* Quand on entre dans la vidéo après un filtrage, on va au premier marqueur correspondant à la recherche (à l'exception d'une recherche infructueuse). |
|
52
|
907 |
* Est appelé dans les fichiers : |
|
|
908 |
* mosaic > fonctions onMouseUp et onMarkersReady. |
|
|
909 |
* curvesDetector > fonction updateDists. |
|
44
|
910 |
*/ |
|
|
911 |
IriSP.Widgets.Timeline.prototype.goToFirstSearchedMarker = function(gesture) |
|
|
912 |
{ |
|
52
|
913 |
if(_.include(this.gestures, gesture)) |
|
|
914 |
{ |
|
|
915 |
if(this.annotations && this.annotations.length > 0) |
|
|
916 |
{ |
|
|
917 |
var minIdx = 0, minPosition = this.source.getDuration().milliseconds, targetCursorPosition = 0; |
|
|
918 |
|
|
|
919 |
//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum. |
|
|
920 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
921 |
{ |
|
|
922 |
//Si le marker n'est pas du type recherché, on passe. |
|
|
923 |
if(this.annotations[i].annotationType.contents.title != gesture) |
|
|
924 |
{ |
|
|
925 |
continue; |
|
|
926 |
} |
|
|
927 |
else if(minPosition > this.annotations[i].begin) |
|
|
928 |
{ |
|
|
929 |
minPosition = this.annotations[i].begin; |
|
|
930 |
minIdx = i; |
|
|
931 |
} |
|
|
932 |
} |
|
|
933 |
|
|
|
934 |
targetCursorPosition = this.annotations[minIdx].begin; |
|
|
935 |
|
|
|
936 |
//Si le marqueur est situé minimum à 1s du début de la video, on place la position cible à 1s avant celle du marqueur recherché. |
|
|
937 |
if(this.annotations[minIdx].begin > 1000) |
|
|
938 |
{ |
|
|
939 |
targetCursorPosition -= 1000; |
|
|
940 |
} |
|
|
941 |
|
|
|
942 |
//On place le marqueur au niveau de la position cible. |
|
|
943 |
this.player.popcorn.currentTime(targetCursorPosition / 1000); |
|
|
944 |
} |
|
|
945 |
} |
|
44
|
946 |
} |
|
|
947 |
|
|
|
948 |
/* |
|
|
949 |
* Renvoie vrai si il y a au moins une gesture de notre recherche dans les marqueurs de la video. |
|
52
|
950 |
* Est appelé dans les fichiers : |
|
|
951 |
* mosaic > fonctions onMouseUp et onMarkersReady. |
|
|
952 |
* curvesDetector > fonction updateDists. |
|
44
|
953 |
*/ |
|
|
954 |
IriSP.Widgets.Timeline.prototype.atLeastOneSearchMarker = function(gesture) |
|
|
955 |
{ |
|
52
|
956 |
if(_.include(this.gestures, gesture)) |
|
|
957 |
{ |
|
|
958 |
if(this.annotations && this.annotations.length > 0) |
|
|
959 |
{ |
|
|
960 |
//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum. |
|
|
961 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
962 |
{ |
|
|
963 |
//Si le marker est reconnu, c'est bon. |
|
|
964 |
if(this.annotations[i].annotationType.contents.title == gesture) |
|
|
965 |
{ |
|
|
966 |
return true; |
|
|
967 |
} |
|
|
968 |
} |
|
|
969 |
|
|
|
970 |
return false; |
|
|
971 |
} |
|
|
972 |
} |
|
31
|
973 |
} |