|
31
|
1 |
/* |
|
|
2 |
The Timeline Widget fits right under the video |
|
|
3 |
*/ |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.Timeline = function(player, config) { |
|
44
|
6 |
|
|
31
|
7 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
8 |
this.bindPopcorn("timeupdate","onTimeupdate"); |
|
|
9 |
this.bindPopcorn("loadedmetadata","ready"); |
|
44
|
10 |
this.bindPopcorn("markersready","onMarkersReady"); |
|
31
|
11 |
//this.bindPopcorn("IriSP.PlayerWidget.MouseOver","onMouseover"); |
|
|
12 |
//this.bindPopcorn("IriSP.PlayerWidget.MouseOut","onMouseout"); |
|
|
13 |
this.timelineSelected = false; |
|
|
14 |
this.markerShowTime = 200; |
|
|
15 |
this.markerLastTime = 5000; |
|
|
16 |
this.markerBigShown = false; |
|
|
17 |
this.currentMarkerIdx = -1; |
|
|
18 |
this.previousMarkerIdx = -1; |
|
|
19 |
this.hideTimeout; |
|
|
20 |
this.currentMode = "VIDEO"; |
|
|
21 |
this.paused = false |
|
|
22 |
this.top_epsilon = 0; |
|
|
23 |
this.imgDir = "player/img/"; |
|
33
|
24 |
this.markersDir = "pictos/small/"; |
|
|
25 |
this.player = player; |
|
44
|
26 |
this.isCurrentlyInASearchByGesture = false; |
|
45
|
27 |
this.mouseInteractions = false; |
|
32
|
28 |
|
|
44
|
29 |
//Id du marqueur enregistré. |
|
|
30 |
this.currentMarkerId; |
|
|
31 |
|
|
45
|
32 |
this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "no-motion", "contact"]; |
|
|
33 |
this.gesturesText = ["chute", "saut", "rotation", "rotation de groupe", "inclinaison", "port de bras", "levé de genou", "angle droit", "ondulation", "immobilité", "contact"]; |
|
32
|
34 |
|
|
|
35 |
this.annotations = this.annotationsFilter(this.source.getAnnotations(), this.gestures, this.isGesture); |
|
|
36 |
|
|
|
37 |
// for(var a = 0 ; a < this.annotations.length ; a++) |
|
|
38 |
// console.log("A : " + this.annotations[a].annotationType.contents.title); |
|
31
|
39 |
}; |
|
|
40 |
|
|
|
41 |
IriSP.Widgets.Timeline.prototype = new IriSP.Widgets.Widget(); |
|
|
42 |
|
|
32
|
43 |
IriSP.Widgets.Timeline.prototype.isGesture = function(element, index, array) |
|
|
44 |
{ |
|
|
45 |
return ($.inArray(element.annotationType.contents.title, array) > -1); |
|
|
46 |
} |
|
|
47 |
|
|
45
|
48 |
/* |
|
|
49 |
* Spécifie si on est en événements souris ou non. |
|
|
50 |
*/ |
|
|
51 |
IriSP.Widgets.Timeline.prototype.setMouseInteractions = function(mouseInteractions) |
|
|
52 |
{ |
|
|
53 |
this.mouseInteractions = mouseInteractions; |
|
|
54 |
|
|
|
55 |
if(mouseInteractions) |
|
|
56 |
{ |
|
|
57 |
this.markersDir += 'MI/'; |
|
|
58 |
} |
|
|
59 |
} |
|
|
60 |
|
|
44
|
61 |
//Fonction associée à l'événement : les marqueurs sont prêts. |
|
|
62 |
IriSP.Widgets.Timeline.prototype.onMarkersReady = function() {} |
|
|
63 |
|
|
32
|
64 |
//Fonction de filtrage de tableaux |
|
|
65 |
IriSP.Widgets.Timeline.prototype.annotationsFilter = function(annotations, gestures, fun /*, thisp*/) |
|
|
66 |
{ |
|
|
67 |
var len = annotations.length; |
|
|
68 |
if (typeof fun != "function") |
|
|
69 |
throw new TypeError(); |
|
|
70 |
|
|
|
71 |
var res = new Array(); |
|
|
72 |
var thisp = arguments[1]; |
|
|
73 |
for (var i = 0; i < len; i++) |
|
|
74 |
{ |
|
|
75 |
if (i in annotations) |
|
|
76 |
{ |
|
|
77 |
var val = annotations[i]; // in case fun mutates this |
|
|
78 |
if (fun.call(thisp, val, i, gestures)) |
|
|
79 |
{ |
|
|
80 |
res.push(val); |
|
|
81 |
} |
|
|
82 |
} |
|
|
83 |
} |
|
|
84 |
return res; |
|
|
85 |
}; |
|
|
86 |
|
|
31
|
87 |
IriSP.Widgets.Timeline.prototype.defaults = { |
|
44
|
88 |
minimized_height : 114,//44, |
|
|
89 |
maximized_height : 114, |
|
|
90 |
middle_height: 10,//4, |
|
31
|
91 |
timelineBorderLength : 6, |
|
|
92 |
minimize_timeout : 1500 // time before minimizing timeline after mouseout |
|
|
93 |
}; |
|
|
94 |
|
|
|
95 |
IriSP.Widgets.Timeline.prototype.draw = function() { |
|
|
96 |
this.$timeline = IriSP.jQuery('<div>') |
|
|
97 |
.addClass("Ldt-Timeline") |
|
|
98 |
.css(this.calculateTimelineCss(this.minimized_height)); |
|
|
99 |
this.$timelineMiddle = IriSP.jQuery('<div>') |
|
|
100 |
.addClass("Ldt-TimelineMiddle") |
|
|
101 |
.css(this.calculateTimelineMiddleCss(this.minimized_height, this.middle_height)); |
|
|
102 |
|
|
|
103 |
/*this.$timelineContainer = IriSP.jQuery('<div>') |
|
|
104 |
.addClass("Ldt-TimelineContainer"); |
|
|
105 |
this.$timelineContainer.append(this.$timeline); |
|
|
106 |
this.$timelineContainer.append(this.$timelineMiddle);*/ |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
this.$.append(this.$timeline); |
|
|
110 |
this.$.append(this.$timelineMiddle); |
|
|
111 |
|
|
|
112 |
var _this = this; |
|
|
113 |
|
|
|
114 |
this.$timeline.slider({ |
|
|
115 |
range: "min", |
|
|
116 |
value: 0, |
|
|
117 |
min: 0, |
|
|
118 |
max: this.source.getDuration().milliseconds, |
|
|
119 |
slide: function(event, ui) { |
|
44
|
120 |
if(_this.player.popcorn) |
|
|
121 |
{ |
|
|
122 |
_this.player.popcorn.currentTime(Math.floor(ui.value/1000)); |
|
|
123 |
_this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime"); |
|
|
124 |
} |
|
31
|
125 |
|
|
|
126 |
// console.log("manual " + _this.previousMarkerIdx); |
|
|
127 |
//On supprime le marqueur précédemment affiché si c'est le cas. |
|
|
128 |
if(_this.previousMarkerIdx > -1) |
|
|
129 |
{ |
|
44
|
130 |
// /!\ var annotations = _this.source.getAnnotations(); |
|
|
131 |
|
|
31
|
132 |
// console.log("EXT hide idx " + _this.previousMarkerIdx); |
|
44
|
133 |
// /!\ var previousMarker = IriSP.jQuery("#" + annotations[_this.previousMarkerIdx].id.replace(":", "_")); |
|
|
134 |
var previousMarker = IriSP.jQuery("#" + _this.annotations[_this.previousMarkerIdx].id.replace(":", "_")); |
|
31
|
135 |
_this.hideMarkerBig(previousMarker); |
|
|
136 |
// console.log("EXT hide " + _this.previousMarkerIdx); |
|
|
137 |
} |
|
|
138 |
} |
|
|
139 |
}); |
|
44
|
140 |
|
|
31
|
141 |
this.$handle = this.$timeline.find('.ui-slider-handle'); |
|
|
142 |
|
|
|
143 |
this.$handle.css(this.calculateHandleCss(this.minimized_height)); |
|
|
144 |
|
|
|
145 |
this.$ |
|
|
146 |
.mouseover(this.functionWrapper("onMouseover")) |
|
|
147 |
.mouseout(this.functionWrapper("onMouseout")); |
|
|
148 |
IriSP.jQuery('body').keypress(function(evt) {_this.keyPress(evt)}); |
|
|
149 |
|
|
|
150 |
this.maximized = false; |
|
|
151 |
this.timeoutId = false; |
|
|
152 |
}; |
|
|
153 |
|
|
|
154 |
/* |
|
|
155 |
* Starts playing the video when it's ready. |
|
|
156 |
*/ |
|
|
157 |
IriSP.Widgets.Timeline.prototype.ready = function() { |
|
|
158 |
this.player.popcorn.play(); |
|
44
|
159 |
this.player.popcorn.mute(); |
|
31
|
160 |
this.processMarkers(); |
|
|
161 |
} |
|
|
162 |
|
|
|
163 |
/* |
|
|
164 |
* Scale a value from [A, B] to [C, D]. |
|
|
165 |
*/ |
|
|
166 |
IriSP.Widgets.Timeline.prototype.scaleIntervals = function(A, B, C, D, val) { |
|
|
167 |
if(C == D) |
|
|
168 |
{ |
|
|
169 |
return C; |
|
|
170 |
} |
|
|
171 |
if(B != A) |
|
|
172 |
{ |
|
|
173 |
return D / (B - A) * (val - A); |
|
|
174 |
} |
|
|
175 |
else |
|
|
176 |
{ |
|
|
177 |
//If A and B have the same sign. |
|
|
178 |
if(A * B > 0) |
|
|
179 |
{ |
|
|
180 |
//If they are positive. |
|
|
181 |
if(A > 0) |
|
|
182 |
{ |
|
|
183 |
return (D - C)/2; |
|
|
184 |
} |
|
|
185 |
else |
|
|
186 |
{ |
|
|
187 |
return (C - D)/2; |
|
|
188 |
} |
|
|
189 |
} |
|
|
190 |
else |
|
|
191 |
{ |
|
|
192 |
return (C + D)/2; |
|
|
193 |
} |
|
|
194 |
} |
|
|
195 |
} |
|
|
196 |
|
|
|
197 |
/* |
|
|
198 |
* Process the markers. |
|
|
199 |
*/ |
|
|
200 |
IriSP.Widgets.Timeline.prototype.processMarkers = function() { |
|
44
|
201 |
console.trace(); |
|
|
202 |
console.log('PROCESSING MARKERS'); |
|
|
203 |
|
|
31
|
204 |
var _this = this; |
|
|
205 |
var markers = ""; |
|
|
206 |
var timelineMiddleTop = this.$timelineMiddle.position().top; |
|
|
207 |
|
|
32
|
208 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
31
|
209 |
{ |
|
32
|
210 |
markers += "<div class='Ldt-Marker' id='" + this.annotations[i].id.replace(":", "_") + "'></div>"; |
|
31
|
211 |
// console.log(annotations[i].begin.milliseconds); |
|
|
212 |
} |
|
|
213 |
|
|
|
214 |
this.$.append(markers); |
|
|
215 |
var markerHeight = IriSP.jQuery(".Ldt-Marker").height(); |
|
|
216 |
IriSP.jQuery(".Ldt-Marker").css("z-align", "150"); |
|
|
217 |
|
|
44
|
218 |
console.log('IN PROCESSING'); |
|
|
219 |
|
|
32
|
220 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
31
|
221 |
{ |
|
32
|
222 |
IriSP.jQuery("#" + this.annotations[i].id.replace(":", "_")).css( |
|
31
|
223 |
{ |
|
|
224 |
top: timelineMiddleTop + "px", |
|
32
|
225 |
left: Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), this.annotations[i].begin/1000) + this.$timeline.position().left) + "px", |
|
31
|
226 |
"margin-top": (-_this.$timeline.height()/2 - markerHeight/2) - this.top_epsilon + "px" |
|
|
227 |
}); |
|
|
228 |
} |
|
44
|
229 |
|
|
|
230 |
console.log('MARKERS PROCESSED'); |
|
|
231 |
|
|
|
232 |
//On lance l'événement pour dire à popcorn que les marqueurs sont utilisables. |
|
|
233 |
// this.player.popcorn.trigger(IriSP.Widgets.Timeline.onMarkersReady); |
|
|
234 |
this.player.popcorn.trigger("markersready"); |
|
|
235 |
//console.log('markers processed'); |
|
|
236 |
} |
|
|
237 |
|
|
|
238 |
/* |
|
|
239 |
* Fonction de recherche par gesures. |
|
|
240 |
*/ |
|
|
241 |
IriSP.Widgets.Timeline.prototype.searchByGesture = function(typeName) |
|
|
242 |
{ |
|
|
243 |
this.notifySearch1Gesture(typeName, "valid"); |
|
|
244 |
|
|
|
245 |
if(typeName != '' || typeName != undefined) |
|
|
246 |
{ |
|
|
247 |
if(_.include(this.gestures, typeName)) |
|
|
248 |
{ |
|
|
249 |
this.currentMode = "SEARCH"; |
|
|
250 |
this.hideMarkersSearch(typeName); |
|
|
251 |
this.isCurrentlyInASearchByGesture = true; |
|
|
252 |
} |
|
|
253 |
else |
|
|
254 |
{ |
|
|
255 |
// alert("Unknown gesture type. Operation aborted."); |
|
45
|
256 |
// this.removeSearch1Gesture(); |
|
|
257 |
// this.notifySearch1Gesture(typeName, "none"); |
|
44
|
258 |
} |
|
|
259 |
} |
|
|
260 |
} |
|
|
261 |
|
|
|
262 |
/* |
|
|
263 |
* Fonction de suppression de recherche par gesures. |
|
|
264 |
*/ |
|
|
265 |
IriSP.Widgets.Timeline.prototype.removeSearchByGesture = function() |
|
|
266 |
{ |
|
|
267 |
this.removeSearch1Gesture(); |
|
|
268 |
this.hideMarkersSearch(); |
|
|
269 |
this.isCurrentlyInASearchByGesture = false; |
|
31
|
270 |
} |
|
|
271 |
|
|
|
272 |
/* |
|
|
273 |
* Place the cursor on the timeline depending on the keytyped. |
|
|
274 |
*/ |
|
|
275 |
IriSP.Widgets.Timeline.prototype.keyPress = function(e) { |
|
|
276 |
var key = this.whichKey(e.which); |
|
|
277 |
var time = 0; |
|
|
278 |
|
|
35
|
279 |
// console.log($(this)); |
|
33
|
280 |
|
|
31
|
281 |
if(key > -1 && key < 11) |
|
|
282 |
{ |
|
|
283 |
time = this.source.getDuration().getSeconds()/10*key; |
|
|
284 |
this.$timeline.slider("value",time); |
|
|
285 |
this.player.popcorn.currentTime(time); |
|
|
286 |
|
|
|
287 |
//On supprime le marqueur précédemment affiché si c'est le cas. |
|
|
288 |
if(this.previousMarkerIdx > -1) |
|
|
289 |
{ |
|
|
290 |
// console.log("EXT hide idx " + this.previousMarkerIdx); |
|
32
|
291 |
var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_")); |
|
31
|
292 |
this.hideMarkerBig(previousMarker); |
|
|
293 |
// console.log("EXT hide " + this.previousMarkerIdx); |
|
|
294 |
} |
|
|
295 |
} |
|
|
296 |
|
|
|
297 |
if(key == 11) |
|
|
298 |
{ |
|
|
299 |
if(!this.timelineSelected) |
|
|
300 |
{ |
|
|
301 |
this.currentMode = "TIMELINE"; |
|
|
302 |
this.selectTimeline(); |
|
|
303 |
} |
|
|
304 |
else |
|
|
305 |
{ |
|
|
306 |
this.currentMode = "VIDEO"; |
|
|
307 |
this.deselectTimeline(); |
|
|
308 |
} |
|
|
309 |
} |
|
|
310 |
|
|
|
311 |
if(key == 12) |
|
|
312 |
{ |
|
|
313 |
this.hideMarkersSearch(); |
|
|
314 |
} |
|
|
315 |
|
|
|
316 |
if(key == 13) |
|
|
317 |
{ |
|
33
|
318 |
var gesturesStr = ''; |
|
|
319 |
for(var i = 0 ; i < this.gestures.length ; i++) |
|
|
320 |
{ |
|
|
321 |
gesturesStr += this.gestures[i] + ", "; |
|
|
322 |
} |
|
|
323 |
gesturesStr = gesturesStr.substr(0, gesturesStr.length - 2); |
|
|
324 |
|
|
|
325 |
/*if(IriSP.jQuery('#notify_search_1gesture').length > 0) |
|
|
326 |
{ |
|
|
327 |
this.removeSearch1Gesture(); |
|
|
328 |
}*/ |
|
|
329 |
|
|
|
330 |
var typeName = prompt("Please enter a type name among (" + gesturesStr + ").", ""); |
|
|
331 |
|
|
45
|
332 |
// this.notifySearch1Gesture(typeName, "valid"); |
|
33
|
333 |
|
|
|
334 |
if(typeName != '' || typeName != undefined) |
|
|
335 |
{ |
|
|
336 |
if(_.include(this.gestures, typeName)) |
|
|
337 |
{ |
|
|
338 |
this.currentMode = "SEARCH"; |
|
|
339 |
this.hideMarkersSearch(typeName); |
|
|
340 |
} |
|
|
341 |
else |
|
|
342 |
{ |
|
35
|
343 |
// alert("Unknown gesture type. Operation aborted."); |
|
45
|
344 |
// this.removeSearch1Gesture(); |
|
|
345 |
// this.notifySearch1Gesture(typeName, "none"); |
|
33
|
346 |
} |
|
|
347 |
} |
|
31
|
348 |
} |
|
|
349 |
|
|
|
350 |
if(key == 21) |
|
|
351 |
{ |
|
|
352 |
// console.log(this); |
|
|
353 |
if(!this.paused) |
|
|
354 |
{ |
|
|
355 |
this.paused = true; |
|
|
356 |
this.player.popcorn.pause(); |
|
|
357 |
} |
|
|
358 |
else |
|
|
359 |
{ |
|
|
360 |
this.paused = false; |
|
|
361 |
this.player.popcorn.play(); |
|
|
362 |
} |
|
|
363 |
} |
|
|
364 |
} |
|
|
365 |
|
|
|
366 |
/* |
|
|
367 |
* Find the key corresponding to a given code. |
|
|
368 |
*/ |
|
|
369 |
IriSP.Widgets.Timeline.prototype.whichKey = function(code) { |
|
|
370 |
var key; |
|
|
371 |
|
|
|
372 |
console.log(code); |
|
|
373 |
|
|
|
374 |
if(code > 47 && code < 58) |
|
|
375 |
{ |
|
|
376 |
return (code - 48); |
|
|
377 |
} |
|
|
378 |
|
|
|
379 |
if(code == 115 || code == 83) |
|
|
380 |
{ |
|
|
381 |
return 11; |
|
|
382 |
} |
|
|
383 |
|
|
33
|
384 |
//m ou M pour quitter une recherche. |
|
|
385 |
if(code == 109 || code == 77) |
|
31
|
386 |
{ |
|
|
387 |
return 12; |
|
|
388 |
} |
|
|
389 |
|
|
|
390 |
//p ou P pour mettre la vidéo en pause. |
|
|
391 |
if(code == 112 || code == 80) |
|
|
392 |
{ |
|
|
393 |
return 21; |
|
|
394 |
} |
|
|
395 |
|
|
33
|
396 |
//n ou N pour une recherche par type. |
|
|
397 |
if(code == 110 || code == 78) |
|
31
|
398 |
{ |
|
|
399 |
return 13; |
|
|
400 |
} |
|
|
401 |
|
|
|
402 |
switch(code) |
|
|
403 |
{ |
|
|
404 |
case 224: |
|
|
405 |
key = 0; |
|
|
406 |
break; |
|
|
407 |
case 38: |
|
|
408 |
key = 1; |
|
|
409 |
break; |
|
|
410 |
case 233: |
|
|
411 |
key = 2; |
|
|
412 |
break; |
|
|
413 |
case 34: |
|
|
414 |
key = 3; |
|
|
415 |
break; |
|
|
416 |
case 39: |
|
|
417 |
key = 4; |
|
|
418 |
break; |
|
|
419 |
case 40: |
|
|
420 |
key = 5; |
|
|
421 |
break; |
|
|
422 |
case 45: |
|
|
423 |
key = 6; |
|
|
424 |
break; |
|
|
425 |
case 232: |
|
|
426 |
key = 7; |
|
|
427 |
break; |
|
|
428 |
case 95: |
|
|
429 |
key = 8; |
|
|
430 |
break; |
|
|
431 |
case 231: |
|
|
432 |
key = 9; |
|
|
433 |
break; |
|
|
434 |
default: |
|
|
435 |
key = -1; |
|
|
436 |
} |
|
|
437 |
|
|
|
438 |
return key; |
|
|
439 |
} |
|
|
440 |
|
|
|
441 |
IriSP.Widgets.Timeline.prototype.selectTimeline = function() { |
|
|
442 |
this.timelineSelected = true; |
|
|
443 |
this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>"; |
|
|
444 |
this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>"; |
|
|
445 |
this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>"; |
|
|
446 |
this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>"; |
|
|
447 |
|
|
|
448 |
this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>"; |
|
|
449 |
this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>"; |
|
|
450 |
|
|
|
451 |
this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown); |
|
|
452 |
|
|
|
453 |
var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height(); |
|
|
454 |
|
|
|
455 |
IriSP.jQuery("#TL_BorderUp").css( |
|
|
456 |
{ |
|
|
457 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
458 |
left: this.$timeline.position().left, |
|
|
459 |
width: this.$timeline.width(), |
|
|
460 |
height: this.timelineBorderLength |
|
|
461 |
}); |
|
|
462 |
IriSP.jQuery("#TL_BorderDown").css( |
|
|
463 |
{ |
|
|
464 |
"margin-top": -this.timelineBorderLength - 2 - this.top_epsilon, |
|
|
465 |
left: this.$timeline.position().left, |
|
|
466 |
width: this.$timeline.width(), |
|
|
467 |
height: this.timelineBorderLength |
|
|
468 |
}); |
|
|
469 |
IriSP.jQuery("#TL_BorderLeft").css( |
|
|
470 |
{ |
|
|
471 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
472 |
left: this.$timeline.position().left, |
|
|
473 |
width: this.timelineBorderLength, |
|
|
474 |
height: this.$timeline.height() |
|
|
475 |
}); |
|
|
476 |
IriSP.jQuery("#TL_BorderRight").css( |
|
|
477 |
{ |
|
|
478 |
"margin-top": -this.$timeline.height() - this.top_epsilon, |
|
|
479 |
left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2, |
|
|
480 |
width: this.timelineBorderLength, |
|
|
481 |
height: this.$timeline.height() |
|
|
482 |
}); |
|
|
483 |
|
|
|
484 |
IriSP.jQuery("#TL_ArrowUp").css( |
|
|
485 |
{ |
|
|
486 |
"background-image": "url(" + this.imgDir + "arrow_up.png)", |
|
|
487 |
"margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon, |
|
|
488 |
left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2, |
|
|
489 |
}); |
|
|
490 |
IriSP.jQuery("#TL_ArrowDown").css( |
|
|
491 |
{ |
|
|
492 |
"background-image": "url(" + this.imgDir + "arrow_down.png)", |
|
|
493 |
"margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon, |
|
|
494 |
left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2, |
|
|
495 |
}); |
|
|
496 |
|
|
|
497 |
IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)"); |
|
|
498 |
} |
|
|
499 |
|
|
|
500 |
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() { |
|
|
501 |
this.timelineSelected = false; |
|
|
502 |
IriSP.jQuery(".TL_Borders").remove(); |
|
|
503 |
IriSP.jQuery(".TL_Arrows").remove(); |
|
|
504 |
IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)"); |
|
|
505 |
} |
|
|
506 |
|
|
|
507 |
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() { |
|
|
508 |
var _time = this.player.popcorn.currentTime(); |
|
|
509 |
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"; |
|
|
510 |
|
|
|
511 |
this.$timeline.slider("value",_time*1000); |
|
|
512 |
IriSP.jQuery(".TL_Arrows").css("display", "block"); |
|
|
513 |
IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft); |
|
|
514 |
IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft); |
|
|
515 |
// this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time}); |
|
|
516 |
//Si on a une distance de 500 ms à un marqueur, on l'affiche. |
|
|
517 |
var nearestMarkerIdx = 0; |
|
32
|
518 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
31
|
519 |
{ |
|
|
520 |
//S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms). |
|
32
|
521 |
if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250) |
|
31
|
522 |
{ |
|
|
523 |
// console.log("1) i = " + i + " " + Math.abs(_time*1000 - annotations[i].begin.milliseconds)); |
|
|
524 |
|
|
|
525 |
//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. |
|
32
|
526 |
if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) < Math.abs(_time*1000 - this.annotations[nearestMarkerIdx].begin.milliseconds) || i == nearestMarkerIdx) |
|
31
|
527 |
{ |
|
|
528 |
// console.log("2) " + Math.abs(_time*1000 - annotations[i].begin.milliseconds) + " < " + Math.abs(_time*1000 - annotations[nearestMarkerIdx].begin.milliseconds)); |
|
|
529 |
//Si le prochain marqueur se situe après le curseur de lecture, on passe donc au marqueur le plus proche. |
|
32
|
530 |
if(_time*1000 < this.annotations[i].begin.milliseconds) |
|
31
|
531 |
{ |
|
|
532 |
// console.log("3) " + _time*1000 + " < " + annotations[i].begin.milliseconds); |
|
|
533 |
// console.log("4) " + "nearest = " + i); |
|
|
534 |
nearestMarkerIdx = i; |
|
|
535 |
// console.log("5a0) before"); |
|
|
536 |
//S'il y a un changement de marqueur (marqueur actuel différent du précédent). |
|
|
537 |
if(nearestMarkerIdx != this.previousMarkerIdx) |
|
|
538 |
{ |
|
32
|
539 |
var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_")); |
|
31
|
540 |
//S'il existe un marqueur précédent, on le cache. |
|
|
541 |
if(this.previousMarkerIdx > -1) |
|
|
542 |
{ |
|
|
543 |
// console.log("hide idx " + this.previousMarkerIdx); |
|
32
|
544 |
var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_")); |
|
31
|
545 |
this.hideMarkerBig(previousMarker); |
|
|
546 |
// console.log("5a) hide " + this.previousMarkerIdx); |
|
|
547 |
} |
|
|
548 |
|
|
|
549 |
// console.log("5b) show " + nearestMarkerIdx); |
|
32
|
550 |
this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title); |
|
31
|
551 |
//Mise à jour du marqueur précédent s'il y a un changement. |
|
|
552 |
this.previousMarkerIdx = nearestMarkerIdx; |
|
|
553 |
// console.log("MAJ : " + this.previousMarkerIdx); |
|
|
554 |
} |
|
|
555 |
} |
|
|
556 |
} |
|
|
557 |
// nearestMarker = (Math.abs(_time*1000 - annotations[i].begin.milliseconds) < Math.abs(_time*1000 - annotations[nearestMarker].begin.milliseconds) && annotations[i].begin.milliseconds >= annotations[nearestMarker].begin.milliseconds && annotations[i].begin.milliseconds >= _time*1000) ? i : nearestMarker; |
|
|
558 |
this.currentMarkerIdx = nearestMarkerIdx; |
|
|
559 |
// this.showMarkerBig(IriSP.jQuery("#" + annotations[i].id.replace(":", "_")), annotations[i].annotationType.contents.title); |
|
|
560 |
} |
|
|
561 |
} |
|
|
562 |
} |
|
|
563 |
|
|
|
564 |
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() { |
|
|
565 |
var _time = this.player.popcorn.currentTime(); |
|
|
566 |
var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) - |
|
|
567 |
this.$timeline.slider("value",_time*1000); |
|
|
568 |
|
|
|
569 |
IriSP.jQuery(".TL_Arrows").css("display", "block"); |
|
|
570 |
IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft); |
|
|
571 |
IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft); |
|
|
572 |
// this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time}); |
|
|
573 |
} |
|
|
574 |
|
|
44
|
575 |
IriSP.Widgets.Timeline.prototype.onMouseover = function() {} |
|
31
|
576 |
|
|
44
|
577 |
IriSP.Widgets.Timeline.prototype.onMouseout = function() {} |
|
31
|
578 |
|
|
44
|
579 |
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {} |
|
31
|
580 |
|
|
|
581 |
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) { |
|
|
582 |
var middleWidth = this.player.config.gui.width; |
|
|
583 |
return { |
|
|
584 |
position: "absolute", |
|
|
585 |
top: "0px", |
|
|
586 |
left: "0px", |
|
|
587 |
width: middleWidth + "px", |
|
|
588 |
height: _size + "px", |
|
|
589 |
"margin-top": (-this.minimized_height - this.top_epsilon) + "px", |
|
|
590 |
"z-align": "50" |
|
|
591 |
}; |
|
|
592 |
} |
|
|
593 |
|
|
|
594 |
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) { |
|
|
595 |
var middleWidth = this.player.config.gui.width; |
|
|
596 |
return { |
|
|
597 |
position: "absolute", |
|
|
598 |
top: "0px", |
|
|
599 |
left: "0px", |
|
|
600 |
width: middleWidth + "px", |
|
|
601 |
height: _middleSize + "px", |
|
|
602 |
"margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px", |
|
|
603 |
"z-align": "100" |
|
|
604 |
}; |
|
|
605 |
} |
|
|
606 |
|
|
|
607 |
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) { |
|
|
608 |
return { |
|
|
609 |
position: "absolute", |
|
|
610 |
top: "0px", |
|
|
611 |
left: "0px", |
|
|
612 |
height: (2 + _size) + "px", |
|
|
613 |
width: (2 + _size) + "px", |
|
|
614 |
"margin-left": -Math.ceil(2 + _size / 2) + "px", |
|
|
615 |
"z-align": "60" |
|
|
616 |
} |
|
|
617 |
} |
|
|
618 |
|
|
|
619 |
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) { |
|
|
620 |
// console.log("avant"); |
|
|
621 |
if(this.markerBigShown) |
|
|
622 |
{ |
|
|
623 |
return; |
|
|
624 |
} |
|
|
625 |
// console.log("apres"); |
|
|
626 |
|
|
|
627 |
clearTimeout(this.hideTimeout); |
|
|
628 |
|
|
|
629 |
var _this = this; |
|
|
630 |
|
|
32
|
631 |
var markerTop, markerLeft; |
|
|
632 |
|
|
|
633 |
if(marker.position() == null) |
|
|
634 |
{ |
|
|
635 |
markerTop = 0; |
|
|
636 |
markerLeft = 0; |
|
|
637 |
} |
|
|
638 |
else |
|
|
639 |
{ |
|
|
640 |
markerTop = marker.position().top; |
|
|
641 |
markerLeft = marker.position().left; |
|
|
642 |
} |
|
|
643 |
|
|
|
644 |
var markerWidth = marker.width(), markerHeight = marker.height(); |
|
31
|
645 |
|
|
|
646 |
this.markerBigShown = true; |
|
44
|
647 |
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>"; |
|
31
|
648 |
this.$.append(markerBig); |
|
|
649 |
|
|
|
650 |
var markerBigText = IriSP.jQuery("#MB_Text"); |
|
|
651 |
var markerBigSpike = IriSP.jQuery("#MB_Spike"); |
|
|
652 |
var markerBigPic = IriSP.jQuery("#MB_Pic"); |
|
|
653 |
|
|
|
654 |
var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight(); |
|
|
655 |
var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height(); |
|
|
656 |
var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height(); |
|
|
657 |
var markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2); |
|
|
658 |
var markerBigTextTop = (parseFloat(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2); |
|
|
659 |
var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2); |
|
|
660 |
|
|
|
661 |
marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)"); |
|
|
662 |
IriSP.jQuery("#MB_Text").css( |
|
|
663 |
{ |
|
|
664 |
top: markerBigTextTop, |
|
|
665 |
left: markerBigTextLeft |
|
|
666 |
}); |
|
|
667 |
IriSP.jQuery("#MB_Spike").css( |
|
|
668 |
{ |
|
|
669 |
left: markerBigSpikeLeft |
|
|
670 |
}); |
|
|
671 |
IriSP.jQuery("#MB_Pic").css( |
|
|
672 |
{ |
|
|
673 |
"background-image": "url(" + this.markersDir + type + ".png)", |
|
|
674 |
top: markerBigPicTop, |
|
44
|
675 |
left: markerBigPicLeft, |
|
|
676 |
"z-index": "400" |
|
31
|
677 |
}); |
|
|
678 |
|
|
|
679 |
IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1"); |
|
|
680 |
|
|
|
681 |
//On rajoute un timeout pour supprimer le marqueur après un certain temps. |
|
|
682 |
this.hideTimeout = setTimeout(function() |
|
|
683 |
{ |
|
|
684 |
_this.hideMarkerBig(marker); |
|
|
685 |
}, this.markerLastTime); |
|
|
686 |
} |
|
|
687 |
|
|
|
688 |
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) { |
|
|
689 |
if(!this.markerBigShown) |
|
|
690 |
{ |
|
|
691 |
return; |
|
|
692 |
} |
|
|
693 |
|
|
|
694 |
this.currentMarker = -1; |
|
|
695 |
this.markerBigShown = false; |
|
|
696 |
marker.css("background-image", "url(" + this.imgDir + "marker.png)"); |
|
|
697 |
|
|
|
698 |
IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove(); |
|
|
699 |
} |
|
|
700 |
|
|
|
701 |
/* |
|
|
702 |
* Affiche le bas des marqueurs correspondants à la recherche. |
|
|
703 |
*/ |
|
|
704 |
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) { |
|
|
705 |
//Si on est en mode SEARCH. |
|
|
706 |
if(this.currentMode != "SEARCH") |
|
|
707 |
{ |
|
|
708 |
return; |
|
|
709 |
} |
|
|
710 |
|
|
|
711 |
var _this = this; |
|
|
712 |
|
|
|
713 |
//On récupère les annotations. |
|
|
714 |
var markersSearch = "", markersPicSearch = ""; |
|
|
715 |
//Pour chaque annotation, on ajoute un double. |
|
32
|
716 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
31
|
717 |
{ |
|
|
718 |
//Si elle correspond à la recherche. |
|
32
|
719 |
if(this.annotations[i].annotationType.contents.title == type) |
|
31
|
720 |
{ |
|
|
721 |
//On récupère le marqueur associé à l'annotation. |
|
32
|
722 |
var markerId = this.annotations[i].id.replace(":", "_"); |
|
31
|
723 |
|
|
|
724 |
markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>"; |
|
|
725 |
markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>"; |
|
|
726 |
} |
|
|
727 |
} |
|
|
728 |
|
|
|
729 |
this.$.append(markersSearch + markersPicSearch); |
|
|
730 |
|
|
|
731 |
//On place chaque double. |
|
32
|
732 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
31
|
733 |
{ |
|
|
734 |
//Si elle correspond à la recherche. |
|
32
|
735 |
if(this.annotations[i].annotationType.contents.title == type) |
|
31
|
736 |
{ |
|
32
|
737 |
var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId); |
|
31
|
738 |
var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height(); |
|
|
739 |
var markerBigPicWidth = parseFloat(IriSP.jQuery(".search_MBPic").css("width")), markerBigPicHeight = parseFloat(IriSP.jQuery(".search_MBPic").css("height")), markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2); |
|
|
740 |
|
|
|
741 |
// console.log(markerLeft + " - " + IriSP.jQuery(".search_MBPic").css("width") + " " + markerBigPicWidth + "/2 " + markerWidth + "/2"); |
|
|
742 |
|
|
|
743 |
IriSP.jQuery("#search_Pic_" + markerId).css( |
|
|
744 |
{ |
|
|
745 |
position: "absolute", |
|
|
746 |
"background-image": "url(" + this.markersDir + type + ".png)", |
|
|
747 |
top: markerBigPicTop, |
|
|
748 |
left: markerBigPicLeft, |
|
|
749 |
"z-index": "300" |
|
|
750 |
}).fadeTo(this.markerShowTime, "1"); |
|
|
751 |
|
|
|
752 |
IriSP.jQuery("#search_Marker_" + markerId).css( |
|
|
753 |
{ |
|
|
754 |
position: "absolute", |
|
|
755 |
top: _this.$timelineMiddle.position().top - _this.top_epsilon, |
|
|
756 |
"margin-top": (-_this.$timeline.height()/2 - markerHeight/2), |
|
|
757 |
"background-image": "url(" + this.imgDir + "selected_marker.png)", |
|
|
758 |
//top: markerTop, |
|
|
759 |
left: markerLeft, |
|
|
760 |
"z-index": "300" |
|
|
761 |
}).fadeTo(this.markerShowTime, "1"); |
|
|
762 |
} |
|
|
763 |
} |
|
|
764 |
} |
|
|
765 |
|
|
|
766 |
/* |
|
|
767 |
* Enlever une recherche faite précédemment. |
|
|
768 |
*/ |
|
|
769 |
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) { |
|
|
770 |
//Si on est en mode SEARCH. |
|
|
771 |
if(this.currentMode != "SEARCH") |
|
|
772 |
{ |
|
|
773 |
return; |
|
|
774 |
} |
|
|
775 |
|
|
44
|
776 |
// console.log('(0)'); |
|
35
|
777 |
|
|
31
|
778 |
var _this = this; |
|
|
779 |
|
|
|
780 |
IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function() |
|
|
781 |
{ |
|
|
782 |
IriSP.jQuery("div").remove(".search_MBPic"); |
|
|
783 |
}); |
|
|
784 |
IriSP.jQuery(".search_Marker").fadeOut(this.markerShowTime, function() |
|
|
785 |
{ |
|
|
786 |
IriSP.jQuery("div").remove(".search_Marker"); |
|
33
|
787 |
_this.removeSearch1Gesture(); |
|
31
|
788 |
|
|
|
789 |
if(type == undefined) |
|
|
790 |
{ |
|
|
791 |
_this.currentMode = "VIDEO"; |
|
|
792 |
} |
|
|
793 |
else |
|
|
794 |
{ |
|
44
|
795 |
// console.log('(1)'); |
|
31
|
796 |
// console.log(_this.currentMode); |
|
|
797 |
_this.showMarkersSearchByType(type); |
|
45
|
798 |
// _this.notifySearch1Gesture(type, "valid"); |
|
31
|
799 |
return; |
|
|
800 |
} |
|
|
801 |
}); |
|
|
802 |
|
|
|
803 |
if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined) |
|
|
804 |
{ |
|
44
|
805 |
// console.log('(2)'); |
|
35
|
806 |
this.showMarkersSearchByType(type); |
|
|
807 |
_this.removeSearch1Gesture(); |
|
|
808 |
|
|
|
809 |
if(!_.include(this.gestures, type)) |
|
33
|
810 |
{ |
|
45
|
811 |
// this.notifySearch1Gesture(type, "none"); |
|
33
|
812 |
} |
|
35
|
813 |
else |
|
|
814 |
{ |
|
45
|
815 |
// _this.notifySearch1Gesture(type, "valid"); |
|
35
|
816 |
} |
|
31
|
817 |
// console.log(this.currentMode); |
|
|
818 |
} |
|
33
|
819 |
} |
|
|
820 |
|
|
|
821 |
IriSP.Widgets.Timeline.prototype.freePlayer = function() |
|
|
822 |
{ |
|
35
|
823 |
IriSP.jQuery('body').unbind('keypress'); |
|
33
|
824 |
IriSP.jQuery('.notifications').remove(); |
|
|
825 |
} |
|
|
826 |
|
|
|
827 |
/* |
|
|
828 |
* Affiche la notification de validation/survol de gesture de recherche. |
|
|
829 |
* Mode prend pour valeurs : "valid" ou "hover". |
|
|
830 |
*/ |
|
|
831 |
IriSP.Widgets.Timeline.prototype.notifySearch1Gesture = function(gestureName, mode) |
|
|
832 |
{ |
|
35
|
833 |
// console.log('C'); |
|
33
|
834 |
if(IriSP.jQuery('#notify_search_1gesture').length > 0) |
|
|
835 |
{ |
|
|
836 |
return; |
|
|
837 |
} |
|
|
838 |
|
|
44
|
839 |
//Si on a effectué une demande de recherche auparavant, on supprime la notification de demande de recherche. |
|
|
840 |
if(IriSP.jQuery('#notify_search').length > 0) |
|
|
841 |
{ |
|
|
842 |
$('.notifications').remove(); |
|
|
843 |
} |
|
|
844 |
|
|
33
|
845 |
var _this = this; |
|
|
846 |
|
|
|
847 |
//On spécifie les notifications en div. |
|
|
848 |
var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>"; |
|
|
849 |
|
|
|
850 |
//On les ajoute à la mosaïque. |
|
44
|
851 |
$('body').append(notification_search_1gesture); |
|
33
|
852 |
|
|
35
|
853 |
// console.log(this.player.config.gui.zoomTop + " " + this.player.config.gui.zoomLeft); |
|
33
|
854 |
|
|
|
855 |
//On calcule leurs coordonnées et dimensions. |
|
|
856 |
var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
|
857 |
var notify_margin = parseInt($('.notifications').css('margin')); |
|
|
858 |
var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
|
859 |
|
|
|
860 |
if(_.include(this.gestures, gestureName)) |
|
|
861 |
{ |
|
35
|
862 |
IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + mode + '/' + gestureName + '.png")'); |
|
33
|
863 |
} |
|
|
864 |
else if(mode == 'none') |
|
|
865 |
{ |
|
|
866 |
IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")'); |
|
|
867 |
} |
|
|
868 |
|
|
|
869 |
if(mode != 'none') |
|
|
870 |
{ |
|
44
|
871 |
/*IriSP.jQuery('#notify_search_1gesture').mouseover(function() |
|
33
|
872 |
{ |
|
|
873 |
IriSP.jQuery(this).css('background-image', 'url("./pictos/big/hover/' + gestureName + '.png")'); |
|
|
874 |
}).mouseout(function() |
|
|
875 |
{ |
|
|
876 |
IriSP.jQuery(this).css('background-image', 'url("./pictos/big/valid/' + gestureName + '.png")'); |
|
|
877 |
}).click(function() |
|
|
878 |
{ |
|
|
879 |
_this.removeSearch1Gesture(); |
|
|
880 |
_this.hideMarkersSearch(); |
|
44
|
881 |
});*/ |
|
33
|
882 |
} |
|
|
883 |
|
|
|
884 |
var notifyTop = this.player.config.gui.zoomTop, notifyLeft = this.player.config.gui.zoomLeft; |
|
|
885 |
|
|
|
886 |
//On les positionne. |
|
|
887 |
$('#notify_search_1gesture').css( |
|
|
888 |
{ |
|
44
|
889 |
// top: -notifyTop, |
|
|
890 |
top: 0,//-notifyTop, |
|
|
891 |
// left: -notifyLeft + (IriSP.jQuery(window).width() - notify_width) / 2 |
|
|
892 |
left: (IriSP.jQuery(window).width() - notify_width) / 2 |
|
33
|
893 |
}); |
|
|
894 |
|
|
|
895 |
//On les fait apparaître. |
|
|
896 |
$('.notifications').css( |
|
|
897 |
{ |
|
|
898 |
opacity: "0.9" |
|
|
899 |
}); |
|
|
900 |
} |
|
|
901 |
|
|
|
902 |
/* |
|
|
903 |
* Supprime la notification de recherche de gesture. |
|
|
904 |
*/ |
|
|
905 |
IriSP.Widgets.Timeline.prototype.removeSearch1Gesture = function() |
|
|
906 |
{ |
|
35
|
907 |
// console.log('R'); |
|
|
908 |
// console.trace(); |
|
33
|
909 |
IriSP.jQuery('#notify_search_1gesture').remove(); |
|
44
|
910 |
} |
|
|
911 |
|
|
|
912 |
/* |
|
|
913 |
* Va au marqueur suivant/précédant lors d'un swipe right/left dans une lecture simple. |
|
|
914 |
* Prend comme argument le fait qu'il s'agisse d'un swipe left ou non (en prenant en condition toujours vraie |
|
|
915 |
* 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. |
|
|
916 |
*/ |
|
|
917 |
IriSP.Widgets.Timeline.prototype.switchToMarker = function(isSwipeLeft, searchedGesture) |
|
|
918 |
{ |
|
|
919 |
console.log((isSwipeLeft == true) ? 'SWIPE LEFT' : 'SWIPE RIGHT'); |
|
|
920 |
|
|
|
921 |
//On prend le temps actuel du curseur en ms. |
|
|
922 |
var currentCursorPosition = this.player.popcorn.currentTime() * 1000; |
|
|
923 |
//Position visée. |
|
|
924 |
var targetCursorPosition = currentCursorPosition; |
|
|
925 |
//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right. |
|
|
926 |
var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0; |
|
|
927 |
|
|
|
928 |
//Si il y a au moins 1 annotation. |
|
|
929 |
if(this.annotations && this.annotations.length > 0) |
|
|
930 |
{ |
|
|
931 |
if(isSwipeLeft) |
|
|
932 |
{ |
|
|
933 |
//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position. |
|
|
934 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
935 |
{ |
|
|
936 |
// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin); |
|
|
937 |
if(currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) |
|
|
938 |
{ |
|
|
939 |
if(searchedGesture != '') |
|
|
940 |
{ |
|
|
941 |
if(this.annotations[i].annotationType.contents.title != searchedGesture) |
|
|
942 |
{ |
|
|
943 |
continue; |
|
|
944 |
} |
|
|
945 |
} |
|
|
946 |
|
|
|
947 |
minDistance = (currentCursorPosition - this.annotations[i].begin); |
|
|
948 |
minIdx = i; |
|
|
949 |
} |
|
|
950 |
} |
|
|
951 |
} |
|
|
952 |
else |
|
|
953 |
{ |
|
|
954 |
//Pour toutes les annotations, on prend celle qui est la plus proche et inférieure à la position. |
|
|
955 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
956 |
{ |
|
|
957 |
if(currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) |
|
|
958 |
{ |
|
|
959 |
if(searchedGesture != '') |
|
|
960 |
{ |
|
|
961 |
if(this.annotations[i].annotationType.contents.title != searchedGesture) |
|
|
962 |
{ |
|
|
963 |
continue; |
|
|
964 |
} |
|
|
965 |
} |
|
|
966 |
|
|
|
967 |
minDistance = (currentCursorPosition - this.annotations[i].begin); |
|
|
968 |
minIdx = i; |
|
|
969 |
} |
|
|
970 |
} |
|
|
971 |
} |
|
|
972 |
|
|
|
973 |
targetCursorPosition = this.annotations[minIdx].begin; |
|
|
974 |
|
|
|
975 |
if(this.annotations[minIdx].begin > 1000) |
|
|
976 |
{ |
|
|
977 |
targetCursorPosition -= 1000; |
|
|
978 |
} |
|
|
979 |
} |
|
|
980 |
|
|
|
981 |
this.player.popcorn.currentTime(targetCursorPosition / 1000); |
|
|
982 |
} |
|
|
983 |
|
|
|
984 |
/* |
|
|
985 |
* Indique s'il y a des marqueurs devant le curseur (pour une recherche) |
|
|
986 |
*/ |
|
|
987 |
IriSP.Widgets.Timeline.prototype.isAMarkerAhead = function(searchedGesture) |
|
|
988 |
{ |
|
|
989 |
if(searchedGesture == '') |
|
|
990 |
{ |
|
|
991 |
return true; |
|
|
992 |
} |
|
|
993 |
|
|
|
994 |
//On prend le temps actuel du curseur en ms. |
|
|
995 |
var currentCursorPosition = this.player.popcorn.currentTime() * 1000; |
|
|
996 |
//Position visée. |
|
|
997 |
var targetCursorPosition = currentCursorPosition; |
|
|
998 |
//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right. |
|
|
999 |
var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0; |
|
|
1000 |
|
|
|
1001 |
//Si il y a au moins 1 annotation. |
|
|
1002 |
if(this.annotations && this.annotations.length > 0) |
|
|
1003 |
{ |
|
|
1004 |
//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position. |
|
|
1005 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1006 |
{ |
|
|
1007 |
// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin); |
|
|
1008 |
if(this.annotations[i].annotationType.contents.title == searchedGesture && currentCursorPosition < this.annotations[i].begin) |
|
|
1009 |
{ |
|
|
1010 |
return true; |
|
|
1011 |
} |
|
|
1012 |
} |
|
|
1013 |
} |
|
|
1014 |
|
|
|
1015 |
return false; |
|
|
1016 |
} |
|
|
1017 |
|
|
|
1018 |
/* |
|
|
1019 |
* Indique, après un swipe, si on est au dernier marqueur d'un type recherché dans la vidéo. |
|
|
1020 |
*/ |
|
|
1021 |
IriSP.Widgets.Timeline.prototype.switchToMarker2 = function(isSwipeLeft, searchedGesture) |
|
|
1022 |
{ |
|
|
1023 |
/*if(isSwipeLeft) |
|
|
1024 |
{ |
|
|
1025 |
//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position. |
|
|
1026 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1027 |
{ |
|
|
1028 |
// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin); |
|
|
1029 |
if(currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) |
|
|
1030 |
{ |
|
|
1031 |
if(searchedGesture != '') |
|
|
1032 |
{ |
|
|
1033 |
if(this.annotations[i].annotationType.contents.title != searchedGesture) |
|
|
1034 |
{ |
|
|
1035 |
continue; |
|
|
1036 |
} |
|
|
1037 |
} |
|
|
1038 |
|
|
|
1039 |
minDistance = (currentCursorPosition - this.annotations[i].begin); |
|
|
1040 |
minIdx = i; |
|
|
1041 |
} |
|
|
1042 |
} |
|
|
1043 |
} |
|
|
1044 |
else |
|
|
1045 |
{ |
|
|
1046 |
//Pour toutes les annotations, on prend celle qui est la plus proche et inférieure à la position. |
|
|
1047 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1048 |
{ |
|
|
1049 |
if(currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) |
|
|
1050 |
{ |
|
|
1051 |
if(searchedGesture != '') |
|
|
1052 |
{ |
|
|
1053 |
if(this.annotations[i].annotationType.contents.title != searchedGesture) |
|
|
1054 |
{ |
|
|
1055 |
continue; |
|
|
1056 |
} |
|
|
1057 |
} |
|
|
1058 |
|
|
|
1059 |
minDistance = (currentCursorPosition - this.annotations[i].begin); |
|
|
1060 |
minIdx = i; |
|
|
1061 |
} |
|
|
1062 |
} |
|
|
1063 |
}*/ |
|
|
1064 |
} |
|
|
1065 |
|
|
|
1066 |
/* |
|
|
1067 |
* 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). |
|
|
1068 |
*/ |
|
|
1069 |
IriSP.Widgets.Timeline.prototype.goToFirstSearchedMarker = function(gesture) |
|
|
1070 |
{ |
|
|
1071 |
if(_.include(this.gestures, gesture)) |
|
|
1072 |
{ |
|
|
1073 |
if(this.annotations && this.annotations.length > 0) |
|
|
1074 |
{ |
|
|
1075 |
var minIdx = 0, minPosition = this.source.getDuration().milliseconds, targetCursorPosition = 0; |
|
|
1076 |
|
|
|
1077 |
//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum. |
|
|
1078 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1079 |
{ |
|
|
1080 |
//Si le marker n'est pas du type recherché, on passe. |
|
|
1081 |
if(this.annotations[i].annotationType.contents.title != gesture) |
|
|
1082 |
{ |
|
|
1083 |
continue; |
|
|
1084 |
} |
|
|
1085 |
else if(minPosition > this.annotations[i].begin) |
|
|
1086 |
{ |
|
|
1087 |
minPosition = this.annotations[i].begin; |
|
|
1088 |
minIdx = i; |
|
|
1089 |
} |
|
|
1090 |
} |
|
|
1091 |
|
|
|
1092 |
targetCursorPosition = this.annotations[minIdx].begin; |
|
|
1093 |
|
|
|
1094 |
console.log('pos : ' + targetCursorPosition); |
|
|
1095 |
|
|
|
1096 |
if(this.annotations[minIdx].begin > 1000) |
|
|
1097 |
{ |
|
|
1098 |
targetCursorPosition -= 1000; |
|
|
1099 |
} |
|
|
1100 |
|
|
|
1101 |
this.player.popcorn.currentTime(targetCursorPosition / 1000); |
|
|
1102 |
} |
|
|
1103 |
} |
|
|
1104 |
} |
|
|
1105 |
|
|
|
1106 |
/* |
|
|
1107 |
* Renvoie vrai si il y a au moins une gesture de notre recherche dans les marqueurs de la video. |
|
|
1108 |
*/ |
|
|
1109 |
IriSP.Widgets.Timeline.prototype.atLeastOneSearchMarker = function(gesture) |
|
|
1110 |
{ |
|
|
1111 |
if(_.include(this.gestures, gesture)) |
|
|
1112 |
{ |
|
|
1113 |
if(this.annotations && this.annotations.length > 0) |
|
|
1114 |
{ |
|
|
1115 |
//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum. |
|
|
1116 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1117 |
{ |
|
|
1118 |
//Si le marker est reconnu, c'est bon. |
|
|
1119 |
if(this.annotations[i].annotationType.contents.title == gesture) |
|
|
1120 |
{ |
|
|
1121 |
return true; |
|
|
1122 |
} |
|
|
1123 |
} |
|
|
1124 |
|
|
|
1125 |
return false; |
|
|
1126 |
} |
|
|
1127 |
} |
|
31
|
1128 |
} |