|
30
|
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 : mosaic.js |
|
|
14 |
* |
|
|
15 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
16 |
* |
|
|
17 |
* Fonctionnalités : Définit la "classe" mosaïque et définit des fonctions d'intéractions. |
|
|
18 |
*/ |
|
|
19 |
|
|
|
20 |
/* |
|
|
21 |
* Classe définissant la mosaïque. |
|
|
22 |
* Elle contient sa longueur, le nombre d'images total, une liste d'urls pour les vidéos, leurs snapshots principaux et leur position. |
|
|
23 |
* Contient également les dimensions en px de la mosaïque. |
|
52
|
24 |
* Est appelé dans : |
|
|
25 |
* la page d'index, afin de créer la mosaique. |
|
30
|
26 |
*/ |
|
52
|
27 |
function Mosaic(config, default_conf) |
|
30
|
28 |
{ |
|
77
|
29 |
this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "no-motion", "contact", "up-down", "grand-jete"]; |
|
44
|
30 |
|
|
52
|
31 |
//Chemin du fichier de configuration. |
|
|
32 |
this.config_path = config; |
|
|
33 |
//Configuration par défaut en cas de valeur erronnée. |
|
|
34 |
this.default_config = default_conf; |
|
|
35 |
this.config = new Object(); |
|
|
36 |
//Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
|
|
37 |
this.videos = []; |
|
|
38 |
this.urls = []; |
|
|
39 |
this.sources = []; |
|
|
40 |
this.imgs = []; |
|
|
41 |
this.opacities = []; |
|
|
42 |
this.timeToGoAt = []; |
|
|
43 |
this.ids = []; |
|
|
44 |
this.fillingIds = []; |
|
|
45 |
this.currentRandomVideoIdx = 0; |
|
|
46 |
|
|
|
47 |
//Dictionnaire pour les courbes de recherche. |
|
|
48 |
this.dictionary = []; |
|
55
|
49 |
|
|
|
50 |
//Strings des notifications. |
|
|
51 |
this.notificationStrings = { |
|
|
52 |
"select":"Select", |
|
|
53 |
"confirm":"Confirm", |
|
|
54 |
"timeline":"Timeline move", |
|
|
55 |
"move":"Move", |
|
|
56 |
"search":"Search", |
|
|
57 |
"next":"Next", |
|
|
58 |
"previous":"Previous", |
|
|
59 |
"unzoom":"Unzoom", |
|
|
60 |
"unknown":"Unknown gesture", |
|
|
61 |
"fall":"Fall", |
|
|
62 |
"jump":"Jump", |
|
|
63 |
"spin":"Spin", |
|
|
64 |
"screw":"Screw", |
|
|
65 |
"bend":"Bend", |
|
|
66 |
"arc":"Arc", |
|
|
67 |
"knee_up":"Knee up", |
|
|
68 |
"breakdance":"Breakdance", |
|
|
69 |
"wave":"Wave", |
|
|
70 |
"no_motion":"No motion", |
|
|
71 |
"contact":"Contact"}; |
|
|
72 |
|
|
|
73 |
this.helpText = { |
|
|
74 |
"search_title":"Search", |
|
|
75 |
"search_2hands_text":"Curves to be drawn with both hands", |
|
|
76 |
"search_mouse_text":"Curves to be mouse-drawn", |
|
|
77 |
"search_body_text":"Gestures to be performed with your body", |
|
|
78 |
"controls_title":"Controls", |
|
|
79 |
"controls_1hand_text":"Gestures to be performed with your hand", |
|
|
80 |
"controls_timeline":"Move in timeline", |
|
|
81 |
"controls_mos_horizontal":"Unzoom", |
|
|
82 |
"controls_mos_vertical":"Unzoom", |
|
|
83 |
"controls_move_down":"Move", |
|
|
84 |
"controls_move_left":"Move", |
|
|
85 |
"controls_move_right":"Move", |
|
|
86 |
"controls_move_up":"Move", |
|
|
87 |
"controls_next":"Next", |
|
|
88 |
"controls_previous":"Previous", |
|
|
89 |
"controls_selection":"Selection" |
|
|
90 |
} |
|
52
|
91 |
|
|
|
92 |
//Dernières positions des pointeurs. |
|
|
93 |
this.mainPointerLastX = null; |
|
|
94 |
this.mainPointerLastY = null; |
|
|
95 |
this.secondPointerLastX = null; |
|
|
96 |
this.secondPointerLastY = null; |
|
|
97 |
//Dernières positions avant le lancement de la fonction d'idle. |
|
|
98 |
this.mainPointerIdleStartX = null; |
|
|
99 |
this.mainPointerIdleStartY = null; |
|
|
100 |
this.secondPointerIdleStartX = null; |
|
|
101 |
this.secondPointerIdleStartY = null; |
|
|
102 |
|
|
|
103 |
//Coordonnées de la souris dans le mode d'interaction souris. |
|
|
104 |
this.mousePosX = null; |
|
|
105 |
this.mousePosY = null; |
|
|
106 |
//Coordonnées précédentes de la souris dans le mode d'interaction souris. |
|
|
107 |
this.mousePosLastX = null; |
|
|
108 |
this.mousePosLastY = null; |
|
|
109 |
//Valeur du déplacement entre un mouse up et un mouse down. |
|
|
110 |
this.mouseUpDownDelta = 0; |
|
77
|
111 |
//Valeur du déplacement entre un touch start et un touch end. |
|
|
112 |
this.touchUpDownDelta = 0; |
|
52
|
113 |
//Coordonnées de la souris au dernier mouse down. |
|
|
114 |
this.mouseDownPosX = null; |
|
|
115 |
this.mouseDownPosY = null; |
|
|
116 |
|
|
|
117 |
//Dimensions de la mosaïque en pixels. |
|
|
118 |
this.width = null; |
|
|
119 |
this.height = null; |
|
|
120 |
//Dimensions d'un snapshot en pixels. |
|
|
121 |
this.snapshotWidth = null; |
|
|
122 |
this.snapshotHeight = null; |
|
|
123 |
//Espacement entre les snapshots en pixels. |
|
|
124 |
this.marginWidth = null; |
|
|
125 |
|
|
|
126 |
//Booléens permettant ou non certaines intéractions selon le contexte. |
|
|
127 |
this.zoomed = false; |
|
|
128 |
this.fullscreen = false; |
|
|
129 |
this.canMoveToNeighbour = false; |
|
|
130 |
this.mainPointerExitBorder = false; |
|
|
131 |
this.secondPointerExitBorder = false; |
|
|
132 |
this.isMainPointerDisplayed = false; |
|
|
133 |
this.isSecondPointerDisplayed = false; |
|
|
134 |
this.helpDisplayed = false; |
|
85
|
135 |
this.creditsDisplayed = false; |
|
52
|
136 |
//Indique si l'utilisateur a manuellement pausé la vidéo. |
|
|
137 |
this.userPaused = false; |
|
|
138 |
//Indique si on est en train de se déplacer vers un voisin. |
|
|
139 |
this.currentlyMoving = false; |
|
|
140 |
//Indique si on est en train de dézoomer vers la mosaïque. |
|
|
141 |
this.currentlyUnzooming = false; |
|
|
142 |
//Indique si on peut s'approcher de kinect. |
|
|
143 |
this.canStart = false; |
|
|
144 |
//Indique si on est actuellement sur un snapshot. |
|
|
145 |
this.isOnASnapshot = false; |
|
|
146 |
//Indique si l'idle des pointeurs est disponible (deux mains détectées). |
|
|
147 |
this.pointersIdleAvailable = false; |
|
|
148 |
//Indique si le timeout pour l'idle des pointeurs à besoin d'être lancé. |
|
|
149 |
this.pointersIdleNeedLaunch = false; |
|
|
150 |
//Indique si les deux mains sont là. |
|
|
151 |
this.areBothPointersHere = false; |
|
|
152 |
//Indique si le timeout pour la détection de deux pointeurs a été lancé. |
|
|
153 |
this.areBothPointersTimeoutLaunched = false; |
|
|
154 |
//Indique si la mosaïque a été filtrée. |
|
|
155 |
this.isMosaicFiltered = false; |
|
|
156 |
//Indique si on est actuellement dans une recherche par gesture. |
|
|
157 |
this.isCurrentlyInASearchByGesture = false; |
|
|
158 |
//Indique si un pointeur est déjà sur une notification de recherche par gesture. |
|
|
159 |
this.alreadyOnNotification = false; |
|
|
160 |
//Si on a fait un swipe. |
|
|
161 |
this.isSwipe = false; |
|
|
162 |
//On peut swiper. |
|
|
163 |
this.canSwipe = false; |
|
|
164 |
//On passe vers une autre video automatiquement à la fin d'une lecture. |
|
|
165 |
this.autoMove = false; |
|
|
166 |
//Si l'utilisateur a demandé à sélectionner la TL. |
|
|
167 |
this.isTLRequested = false; |
|
|
168 |
//Le pointeur gauche a sélectionné la TL. |
|
|
169 |
this.isTLSelectedBySecondPointer = false; |
|
|
170 |
//Le pointeur droit a sélectionné la TL. |
|
|
171 |
this.isTLSelectedByMainPointer = false; |
|
|
172 |
//On peut afficher l'aide. |
|
|
173 |
this.canNotifyHelp = false; |
|
|
174 |
//Indique si la mosaique est en train d'être filtrée. |
|
|
175 |
this.isMosaicFiltering = false; |
|
|
176 |
this.arrowLeftLoading = false; |
|
|
177 |
this.arrowRightLoading = false; |
|
|
178 |
this.arrowUpLoading = false; |
|
|
179 |
this.arrowDownLoading = false; |
|
|
180 |
//On est dans une recherche par courbes. |
|
|
181 |
this.isSearchByCurvesOn = false; |
|
|
182 |
this.canDrawNextCurve = false; |
|
|
183 |
//Dans le mode d'interaction souris, indique si on se situe actuellement sur un snapshot entièrement prézoomé. |
|
|
184 |
this.isOnAPrezoomSN = false; |
|
|
185 |
//Indique si une courbe de recherche donne au moins un résultat. |
|
|
186 |
this.curvesGesturesFound = false; |
|
|
187 |
//Indique si on souhaite supprimer la recherche en cours. |
|
|
188 |
this.gestureDelRequested = false; |
|
|
189 |
//Code de gesture actuellement calculé par les détecteurs de courbes. |
|
|
190 |
this.actualCode = ''; |
|
|
191 |
//Indique si l'utilisateur est entré dans la zone de recherche. |
|
|
192 |
this.isUserInSearchZone = false; |
|
77
|
193 |
//Indique si on a fait un mouse down. |
|
52
|
194 |
this.isMouseDown = false; |
|
77
|
195 |
//Indique si on a fait un touch start. |
|
|
196 |
this.isTouchStart = false; |
|
|
197 |
//Indique si on a fait un touch move. |
|
|
198 |
this.isTouchMove = false; |
|
52
|
199 |
//Indique si on est en train de prézoomer. |
|
|
200 |
this.isPrezooming = false; |
|
55
|
201 |
//Indique si l'icone d'aide a été agrandie. |
|
|
202 |
this.isHelpIconZoomed = false; |
|
|
203 |
//Indique si l'icone d'aide est dans une interaction de zoom/dezoom en cours. |
|
|
204 |
this.isHelpIconZooming = false; |
|
85
|
205 |
//Indique si l'icone des crédits a été agrandie. |
|
|
206 |
this.isCreditsIconZoomed = false; |
|
|
207 |
//Indique si l'icone des crédits est dans une interaction de zoom/dezoom en cours. |
|
|
208 |
this.isCreditsIconZooming = false; |
|
58
|
209 |
//Indique à l'utilisateur s'il doit retirer ses mains pour refaire une recherche par courbes. |
|
|
210 |
this.mustTakeOutHands = false; |
|
79
|
211 |
//Indique qu'une vidéo est en lecture. |
|
|
212 |
this.isVideoReading = false; |
|
77
|
213 |
|
|
|
214 |
//Indique si on est sur une tablette. |
|
|
215 |
this.isTablet = ('ontouchstart' in document.documentElement); |
|
52
|
216 |
|
|
|
217 |
//Timeout (attente) pour le zoom après un préZoom. |
|
|
218 |
this.zoomTimeout = null; |
|
|
219 |
//Timeout (attente) pour le passage vers un voisin. |
|
|
220 |
this.moveToNeighbourTimeout = null; |
|
|
221 |
this.mainPointerExitBorderTimeout = null; |
|
|
222 |
this.secondPointerExitBorderTimeout = null; |
|
|
223 |
//Idle time pour les pointeurs afin d'informer le front qu'on souhaite faire une recherche. |
|
|
224 |
this.pointersSearchIdleTimeout = null; |
|
|
225 |
//Vérifie toutes les N ms que les deux pointeurs sont détectés. |
|
|
226 |
this.areBothPointersHereTimeout = null; |
|
|
227 |
//Délai de suppression d'une notification de recherche par gesture. |
|
|
228 |
this.removeNotificationByGestureTimeout = null; |
|
|
229 |
//Délai de suppression d'une notification de recherche par gesture infructueuse. |
|
|
230 |
this.removeFailedNotificationByGestureTimeout = null; |
|
|
231 |
//Délai avant la suppression de notification swipe. |
|
|
232 |
this.notifySwipeTimeout = null; |
|
|
233 |
//Délai pour la sélection de la TL. |
|
|
234 |
this.selectTLTimeout = null; |
|
|
235 |
//Délai pour slider sur la TL. |
|
|
236 |
this.canSlideInTLTimeout = null; |
|
|
237 |
//Délai pour afficher l'aide. |
|
|
238 |
this.canNotifyHelpTimeout = null; |
|
|
239 |
this.arrowLeftTimeout = null; |
|
|
240 |
this.arrowRightTimeout = null; |
|
|
241 |
this.arrowUpTimeout = null; |
|
|
242 |
this.arrowDownTimeout = null; |
|
|
243 |
|
|
|
244 |
this.arrowSpinnerTimeout = null; |
|
|
245 |
this.nouserTimeout = null; |
|
|
246 |
this.nextDrawCurveTimeout = null; |
|
|
247 |
|
|
|
248 |
//Dernier message INCOMING (pour éviter d'effectuer n fois la même action. |
|
|
249 |
this.lastIncomingMessage = ''; |
|
|
250 |
|
|
|
251 |
//Type de marqueur recherché dans la mosaïque (en mode filter). |
|
|
252 |
this.filterSearchedType = ""; |
|
|
253 |
|
|
|
254 |
//Mode actuel. |
|
|
255 |
this.currentMode = "NO-USER"; |
|
|
256 |
//Snapshot sur lequel on a zoomé. |
|
|
257 |
this.previousZoomedSN = null; |
|
|
258 |
//Snapshot sur lequel on a prezoomé. |
|
|
259 |
this.previousPrezoomDiv = null; |
|
|
260 |
//Son ID. |
|
|
261 |
this.previousId = null; |
|
|
262 |
//Dernier snapshot prézoomé non null. |
|
|
263 |
this.lastNonNullSN = null; |
|
|
264 |
//Largeur de la marge pour le centrage vertical de la mosaïque. |
|
|
265 |
this.MPTop_margin = null; |
|
|
266 |
this.top_margin = null; |
|
|
267 |
|
|
|
268 |
//Gestures actuellement cherchées dans les vidéos. |
|
|
269 |
this.currentSearchGesture = []; |
|
|
270 |
|
|
|
271 |
//Position des voisins lors d'un zoom. |
|
|
272 |
this.neighboursIds = []; |
|
|
273 |
//ID du snapshot du milieu lors d'un zoom. |
|
|
274 |
this.centerId = null; |
|
|
275 |
|
|
|
276 |
//Voisins sélectionnés par les pointeurs. |
|
|
277 |
this.mainPointerNeighbourSelectedId = null; |
|
|
278 |
this.secondPointerNeighbourSelectedId = null; |
|
|
279 |
|
|
|
280 |
//Snapshots a afficher. |
|
|
281 |
this.snapshotsToShow = 1; |
|
|
282 |
|
|
|
283 |
//Lecteur. |
|
|
284 |
this.player = null; |
|
|
285 |
//Si le lecteur est prêt. |
|
|
286 |
this.playerIsReady = false; |
|
|
287 |
|
|
|
288 |
//Annotations (pour les marqueurs los d'un filtrage). |
|
|
289 |
this.annotations = []; |
|
|
290 |
|
|
|
291 |
//Client websocket pour recevoir les notifications du Middleware. |
|
|
292 |
this.client = null; |
|
|
293 |
|
|
|
294 |
//Coordonnées et dimensions d'un snapshot zoomé. |
|
|
295 |
this.snTop = 0; |
|
|
296 |
this.snLeft = 0; |
|
|
297 |
this.snWidth = 0; |
|
|
298 |
this.snHeight = 0; |
|
|
299 |
|
|
|
300 |
this.searchCanvas = null; |
|
|
301 |
//Position actuelle de la vidéo zoomée. |
|
|
302 |
this.notifyTopVideo = null; |
|
|
303 |
this.notifyLeftVideo = null; |
|
|
304 |
this.loadParameters(this.config_path); |
|
30
|
305 |
} |
|
|
306 |
|
|
|
307 |
/* |
|
|
308 |
* Méthode d'affichage de la mosaïque. |
|
|
309 |
* Génère une matrice de imgs. |
|
52
|
310 |
* Est appelé dans le fichier : |
|
|
311 |
* mosaic > fonction loadMosaic, afin de créer les éléments visuels de la mosaique. |
|
30
|
312 |
*/ |
|
52
|
313 |
Mosaic.prototype.createMosaic = function() |
|
30
|
314 |
{ |
|
52
|
315 |
var _this = this; |
|
|
316 |
|
|
|
317 |
//On ajoute le player au body pour le lancer la première fois qu'on zoom. |
|
|
318 |
$('body').append('<div class="player" id="video"></div><div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
|
319 |
|
|
|
320 |
//On recharge la fenêtre si sa taille a changé. |
|
|
321 |
$(window).resize(function() |
|
35
|
322 |
{ |
|
77
|
323 |
// _.debounce(window.location.reload(), _this.config.timeReloadAfterResize); |
|
35
|
324 |
}); |
|
|
325 |
|
|
52
|
326 |
var initPanel = '<div id="initPanel"></div>'; |
|
|
327 |
var mp = $('#mainPanel'); |
|
|
328 |
mp.append(initPanel); |
|
|
329 |
$('#initPanel').css( |
|
|
330 |
{ |
|
|
331 |
background: 'transparent', |
|
|
332 |
width: mp.width(), |
|
|
333 |
height: mp.height(), |
|
|
334 |
top: mp.position().top, |
|
|
335 |
left: mp.position().left, |
|
|
336 |
'margin-top': this.MPTop_margin |
|
|
337 |
}); |
|
|
338 |
|
|
55
|
339 |
var len = this.config.imagesByLine, imgs = this.config.imagesToShow, imgsTotal = this.config.imagesTotal; |
|
52
|
340 |
|
|
|
341 |
//S'il s'agit d'un rectangle. |
|
35
|
342 |
if(imgs % len == 0) |
|
30
|
343 |
{ |
|
52
|
344 |
this.lastIncomingMessage = 'INCOMING-0'; |
|
|
345 |
|
|
|
346 |
var str = ''; |
|
|
347 |
|
|
|
348 |
if(this.imgs.length >= imgs) |
|
|
349 |
{ |
|
|
350 |
for(var i = 0 ; i < imgs ; i++) |
|
|
351 |
{ |
|
|
352 |
//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global. |
|
|
353 |
str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>'; |
|
|
354 |
//Au départ aucune vidéo n'a de gesture de recherche. |
|
|
355 |
this.currentSearchGesture[i] = ''; |
|
|
356 |
} |
|
|
357 |
} |
|
|
358 |
|
|
77
|
359 |
return str; |
|
52
|
360 |
} |
|
|
361 |
else |
|
|
362 |
{ |
|
|
363 |
alert("Le nombre d'images a afficher doit être divisible par la longueur de la mosaïque !"); |
|
|
364 |
} |
|
|
365 |
} |
|
|
366 |
|
|
|
367 |
/* |
|
|
368 |
* Permet de raffraichir la mosaïque. |
|
|
369 |
* Est appelé dans le fichier : |
|
|
370 |
* mosaic > fonction loadFromJson, afin de charger la mosaique une fois que les fichiers de métadonnées ont été lus. |
|
|
371 |
*/ |
|
|
372 |
Mosaic.prototype.loadMosaic = function() |
|
|
373 |
{ |
|
|
374 |
// console.log('LOAD'); |
|
|
375 |
var createMosaic = this.createMosaic(); |
|
|
376 |
|
|
|
377 |
if(createMosaic == '') |
|
|
378 |
{ |
|
|
379 |
return; |
|
|
380 |
} |
|
|
381 |
|
|
|
382 |
var _this = this; |
|
|
383 |
|
|
30
|
384 |
//On affecte les chemins vers les images à la mosaïque. |
|
|
385 |
this.previousZoomedSN; |
|
|
386 |
//On met à jour la mosaïque. |
|
32
|
387 |
$('#mainPanel').html(createMosaic); |
|
77
|
388 |
//On ajoute le panneau de protection (principalement pour le mode tablettes). |
|
|
389 |
$('body').append('<div id="ghostPanel"></div>'); |
|
30
|
390 |
//On récupère la taille des bordures. |
|
|
391 |
this.marginWidth = $('.snapshotDivs').css('margin-bottom'); |
|
35
|
392 |
this.marginWidth = parseFloat(this.marginWidth)*2; |
|
30
|
393 |
//On calcule la taille des divs contenant les snapshots. |
|
|
394 |
this.width = $('#mainPanel').innerWidth(); |
|
|
395 |
//On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement. |
|
55
|
396 |
this.snapshotWidth = this.width / this.config.imagesByLine - this.marginWidth; |
|
30
|
397 |
this.snapshotHeight = this.snapshotWidth*9/16; |
|
77
|
398 |
$('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin-left', this.marginWidth/2); |
|
30
|
399 |
|
|
|
400 |
this.height = $('#mainPanel').innerHeight(); |
|
|
401 |
//On centre verticalement la mosaïque. |
|
|
402 |
this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2; |
|
|
403 |
$('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin); |
|
52
|
404 |
|
|
|
405 |
//On fait coincider le background du body avec celui de la mosaïque. |
|
|
406 |
$('body').css('background-position', '0px ' + this.MPTop_margin + 'px'); |
|
|
407 |
|
|
|
408 |
this.addPointers(); |
|
|
409 |
|
|
|
410 |
//Si dans le metadata player _ n'est pas déclaré, on le déclare. |
|
|
411 |
if(typeof _ !== "undefined" && typeof IriSP._ === "undefined") |
|
|
412 |
{ |
|
|
413 |
IriSP._ = _; |
|
|
414 |
} |
|
|
415 |
|
|
|
416 |
if(typeof $ !== "undefined" && typeof IriSP.jQuery === "undefined") |
|
|
417 |
{ |
|
|
418 |
IriSP.jQuery = $; |
|
|
419 |
} |
|
|
420 |
|
|
|
421 |
//On charge les marqueurs. |
|
|
422 |
var sourceManager = new IriSP.Model.Directory(), |
|
|
423 |
globalAnnotations = new IriSP.Model.List(sourceManager), |
|
|
424 |
nbFichiers = _this.urls.length, |
|
|
425 |
fichiersCharges = 0; |
|
|
426 |
|
|
|
427 |
//Récupère les annotations. |
|
|
428 |
for (var i = 0; i < nbFichiers; i++) |
|
|
429 |
{ |
|
|
430 |
_this.sources[i] = sourceManager.remoteSource({url: _this.urls[i], serializer: IriSP.serializers.ldt}); |
|
|
431 |
_this.sources[i].onLoad(function() |
|
|
432 |
{ |
|
|
433 |
var source = this; |
|
|
434 |
globalAnnotations.addElements(source.getAnnotations()); |
|
|
435 |
fichiersCharges++; |
|
|
436 |
if (fichiersCharges == nbFichiers) |
|
|
437 |
{ |
|
|
438 |
//Instructions à exécuter quand tout est chargé. |
|
|
439 |
_this.annotations = globalAnnotations; |
|
|
440 |
// console.log(_this.annotations.length + ' annotations loaded from ' + nbFichiers + ' files.'); |
|
|
441 |
|
|
|
442 |
//Si on gère les interactions à la souris. |
|
|
443 |
if(_this.config.mouseInteractions) |
|
|
444 |
{ |
|
77
|
445 |
//On bind les événements utiles. |
|
|
446 |
_this.eventBinder(); |
|
52
|
447 |
} |
|
|
448 |
|
|
|
449 |
//Si on a activé la préphase mais qu'on est en mode Kinect. |
|
|
450 |
if(_this.config.noUserModeEnabled && !_this.config.mouseInteractions) |
|
|
451 |
{ |
|
|
452 |
//On active la préphase. |
|
|
453 |
_this.init(); |
|
|
454 |
_this.showNImages(0); |
|
|
455 |
_this.currentMode = "NO-USER"; |
|
|
456 |
} |
|
|
457 |
else |
|
|
458 |
{ |
|
|
459 |
//Sinon on affiche directement la mosaique. |
|
|
460 |
_this.showNImages(20); |
|
|
461 |
_this.currentMode = "MOSAIC"; |
|
|
462 |
} |
|
|
463 |
|
|
|
464 |
//Le premier snapshot sur lequel on zoom en préphase. |
|
|
465 |
_this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]); |
|
|
466 |
} |
|
|
467 |
}); |
|
|
468 |
} |
|
77
|
469 |
} |
|
|
470 |
|
|
|
471 |
/* |
|
|
472 |
* Bind les événements souris ou touch dans le mode d'interaction souris. |
|
|
473 |
*/ |
|
|
474 |
Mosaic.prototype.eventBinder = function() |
|
|
475 |
{ |
|
|
476 |
var _this = this; |
|
|
477 |
|
|
|
478 |
//On affiche l'icone d'aide. |
|
|
479 |
this.helpIcon(); |
|
85
|
480 |
//On affiche l'icone des crédits. |
|
|
481 |
this.creditsIcon(); |
|
77
|
482 |
|
|
|
483 |
//Si on est sur tablette, on utilise l'événement touch start. |
|
|
484 |
if(this.isTablet) |
|
|
485 |
{ |
|
|
486 |
document.addEventListener('touchstart', function(e) |
|
|
487 |
{ |
|
|
488 |
if(e.touches.length == 1) |
|
|
489 |
{ |
|
|
490 |
var touch = e.touches[0]; |
|
|
491 |
_this.onTouchStart(touch); |
|
|
492 |
} |
|
|
493 |
e.preventDefault(); |
|
|
494 |
}, false); |
|
|
495 |
} |
|
|
496 |
//Sinon souris. |
|
|
497 |
else |
|
|
498 |
{ |
|
|
499 |
//Si on fait un mouse down sur le body, on vérifie enregistre le déplacement de la souris jusqu'au prochain mouse up. |
|
|
500 |
$(window).mousedown(function (e) |
|
|
501 |
{ |
|
52
|
502 |
_this.onMouseDown(e); |
|
|
503 |
return false; |
|
77
|
504 |
}); |
|
|
505 |
} |
|
|
506 |
|
|
|
507 |
//Si on est sur tablette, on utilise l'événement touch start. |
|
|
508 |
if(this.isTablet) |
|
|
509 |
{ |
|
|
510 |
document.addEventListener('touchmove', function(e) |
|
|
511 |
{ |
|
|
512 |
if(e.touches.length == 1) |
|
|
513 |
{ |
|
|
514 |
var touch = e.touches[0]; |
|
|
515 |
_this.refreshPointers(touch.pageX, touch.pageY, true); |
|
|
516 |
_this.mousePosX = touch.pageX; |
|
|
517 |
_this.mousePosY = touch.pageY; |
|
|
518 |
_this.onTouchMove(touch); |
|
|
519 |
} |
|
|
520 |
e.preventDefault(); |
|
|
521 |
}, false); |
|
|
522 |
} |
|
|
523 |
//Sinon souris. |
|
|
524 |
else |
|
|
525 |
{ |
|
52
|
526 |
//On écoute le déplacement de la souris. |
|
|
527 |
$(window).mousemove(function(e) |
|
35
|
528 |
{ |
|
77
|
529 |
_this.refreshPointers(e.pageX, e.pageY, true); |
|
|
530 |
_this.mousePosX = e.pageX; |
|
|
531 |
_this.mousePosY = e.pageY; |
|
52
|
532 |
_this.onMouseMove(e); |
|
|
533 |
return false; |
|
|
534 |
}); |
|
77
|
535 |
} |
|
|
536 |
|
|
|
537 |
//Si on est sur tablette, on utilise l'événement touch start. |
|
|
538 |
if(this.isTablet) |
|
|
539 |
{ |
|
|
540 |
document.addEventListener('touchend', function(e) |
|
|
541 |
{ |
|
|
542 |
_this.onTouchEnd(e); |
|
|
543 |
e.preventDefault(); |
|
|
544 |
}, false); |
|
|
545 |
} |
|
|
546 |
//Sinon souris. |
|
|
547 |
else |
|
|
548 |
{ |
|
52
|
549 |
//Si on fait un mouse up après ce mouse down. |
|
|
550 |
$(window).mouseup(function() |
|
|
551 |
{ |
|
|
552 |
_this.onMouseUp(); |
|
|
553 |
return false; |
|
|
554 |
}); |
|
77
|
555 |
} |
|
|
556 |
|
|
|
557 |
if(!this.isTablet) |
|
|
558 |
{ |
|
52
|
559 |
//Si on fait un clic. |
|
|
560 |
$(window).click(function(e) |
|
|
561 |
{ |
|
|
562 |
_this.onClick(e.pageX, e.pageY); |
|
|
563 |
_this.removeSearchNotificationIfOnIt(e.pageX, e.pageY); |
|
|
564 |
return false; |
|
|
565 |
}); |
|
|
566 |
|
|
|
567 |
$(window).on('mousewheel', function(event, delta, deltaX, deltaY) |
|
77
|
568 |
{ |
|
52
|
569 |
//Si on est dans un mode autre qu'on mode zoomé ou que l'aide est affichée, on part. |
|
|
570 |
if(_this.currentMode != "VIDEO" && _this.currentMode != "SEARCH" && _this.currentMode != "TIMELINE" || _this.helpDisplayed) |
|
35
|
571 |
{ |
|
52
|
572 |
return; |
|
45
|
573 |
} |
|
|
574 |
|
|
77
|
575 |
//Quand on "tire" la molette vers soi, on dezoom. |
|
|
576 |
if (delta < 0) |
|
|
577 |
{ |
|
|
578 |
_this.unzoom(); |
|
|
579 |
} |
|
|
580 |
}); |
|
|
581 |
} |
|
35
|
582 |
} |
|
|
583 |
|
|
|
584 |
/* |
|
|
585 |
* Charge les paramètres du Front. Local (true/false) est le mode de chargement des données. |
|
52
|
586 |
* Est appelé dans le fichier : |
|
|
587 |
* mosaic > fonction Mosaic, est appelée dans le constructeur de manière à charger les paramètres de configuration avant la création de la mosaique. |
|
35
|
588 |
*/ |
|
52
|
589 |
Mosaic.prototype.loadParameters = function(file_path) |
|
35
|
590 |
{ |
|
52
|
591 |
var _this = this; |
|
|
592 |
|
|
|
593 |
//Variables censées être des ints. |
|
77
|
594 |
var supposedToBeInt = ['imagesByLine', 'imagesToShow', 'totalImages', 'timeReloadAfterResize', 'timePrezoom', 'timePreUnzoom', 'zoomTime', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeANFade', 'timeFilling', 'zoomedMargin', 'timeoutZoom', 'timeoutUnzoom', 'timeoutMoveToNeighbour', 'timeoutPointersIdle', 'timeoutAreBothPointersHere', 'timeoutRemoveNotificationByGesture', 'timeoutNotifySwipe', 'timeoutSelectTL', 'timeoutSlideTL', 'timeoutCanNotifyHelp', 'timeoutRemoveSpinner', 'timeoutNouser', 'timeoutNextDrawCurve', 'touchUpDownDeltaTreshold', 'mouseUpDownDeltaTreshold', 'kinectUpDownDeltaTreshold', 'helpBorderSize']; |
|
52
|
595 |
//Variables censées êtres des floats. |
|
|
596 |
var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage']; |
|
|
597 |
|
|
|
598 |
//On lit le fichier de configuration. |
|
|
599 |
$.getJSON(file_path, function(data) |
|
|
600 |
{ |
|
|
601 |
//Pour chaque ligne du fichier. |
|
|
602 |
for(key in data) |
|
|
603 |
{ |
|
|
604 |
var val = data[key]; |
|
|
605 |
|
|
|
606 |
//Si la valeur est prise pour un int. |
|
|
607 |
if(_.include(supposedToBeInt, key)) |
|
|
608 |
{ |
|
|
609 |
//On la parse et s'il y a une erreur, on l'indique dans la console avant d'affecter la valeur par défaut. |
|
|
610 |
//Sinon on lui affecte la valeur lue. |
|
|
611 |
var intVal = parseInt(val); |
|
|
612 |
if(isNaN(intVal)) |
|
|
613 |
{ |
|
|
614 |
_this.config[key] = _this.default_config[key]; |
|
|
615 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Int). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
616 |
} |
|
|
617 |
else |
|
|
618 |
{ |
|
|
619 |
_this.config[key] = intVal; |
|
|
620 |
} |
|
|
621 |
} |
|
|
622 |
//Si la valeur est prise pour un float. |
|
|
623 |
else if(_.include(supposedToBeFloat, key)) |
|
|
624 |
{ |
|
|
625 |
//On la parse et s'il y a une erreur, on l'indique dans la console avant d'affecter la valeur par défaut. |
|
|
626 |
//Sinon on lui affecte la valeur lue. |
|
|
627 |
var floatVal = parseFloat(val); |
|
|
628 |
if(isNaN(floatVal)) |
|
|
629 |
{ |
|
|
630 |
_this.config[key] = _this.default_config[key]; |
|
|
631 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Float). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
632 |
} |
|
|
633 |
else |
|
|
634 |
{ |
|
|
635 |
_this.config[key] = floatVal; |
|
|
636 |
} |
|
|
637 |
} |
|
|
638 |
else |
|
|
639 |
{ |
|
|
640 |
//S'il s'agit de la langue, on met par défaut si la valeur est nulle. |
|
|
641 |
if(key == 'lang' && val == '') |
|
35
|
642 |
{ |
|
|
643 |
_this.config[key] = _this.default_config[key]; |
|
|
644 |
} |
|
52
|
645 |
//Sinon si c'est une string, on l'affecte. |
|
35
|
646 |
else |
|
|
647 |
{ |
|
52
|
648 |
_this.config[key] = val; |
|
35
|
649 |
} |
|
52
|
650 |
} |
|
|
651 |
} |
|
|
652 |
|
|
|
653 |
//On remplit le tableau d'ids. |
|
|
654 |
for(var i = 0 ; i < _this.config.totalImages ; i++) |
|
|
655 |
_this.ids.push(i); |
|
|
656 |
//On les mélange. |
|
|
657 |
_this.ids = _.shuffle(_this.ids); |
|
|
658 |
|
|
|
659 |
//On remplit le tableau d'ids destiné à afficher les snapshots au fur et à mesure. |
|
|
660 |
for(var i = 0 ; i < _this.config.imagesToShow ; i++) |
|
|
661 |
_this.fillingIds.push(i); |
|
|
662 |
//On les mélange. |
|
|
663 |
_this.fillingIds = _.shuffle(_this.fillingIds); |
|
|
664 |
|
|
|
665 |
//Si la config spécifie le chargement comme étant local/en ligne, on charge le fichier des vidéos approprié. |
|
|
666 |
if(_this.config.local) |
|
|
667 |
{ |
|
|
668 |
_this.loadFromJson(_this.config.videoConfigFileLocal); |
|
|
669 |
} |
|
|
670 |
else |
|
|
671 |
{ |
|
|
672 |
_this.loadFromJson(_this.config.videoConfigFileOnline); |
|
|
673 |
} |
|
|
674 |
|
|
|
675 |
//On initialise le client dans le cas d'intéractions Kinect. |
|
|
676 |
if(!_this.config.mouseInteractions) |
|
|
677 |
{ |
|
|
678 |
_this.client = new Client(_this.config.host, _this.config.port, _this); |
|
|
679 |
} |
|
|
680 |
|
|
|
681 |
//On prend le dictionnaire stockant les codes des courbes de recherche. |
|
|
682 |
_this.getDictionary(); |
|
|
683 |
//On charge le fichier des langues. |
|
|
684 |
_this.getLang(); |
|
|
685 |
}); |
|
30
|
686 |
} |
|
|
687 |
|
|
|
688 |
/* |
|
35
|
689 |
* Phase principale (utilisateur non détecté). Une vidéo se lance aléatoirement. |
|
|
690 |
* L'interface est identique à celle du zoom, mais sans interaction possible avec les voisins, ni les controles timeline. |
|
|
691 |
* Lors de la fin d'une lecture, on dézoome vers la mosaïque, puis on rezoome vers un autre snapshot (aléatoire). |
|
52
|
692 |
* Est appelé dans les fichiers : |
|
|
693 |
* mosaic > fonction loadMosaic. |
|
|
694 |
* zoomInteractions > fonction unzoom. |
|
35
|
695 |
*/ |
|
52
|
696 |
Mosaic.prototype.init = function() |
|
35
|
697 |
{ |
|
52
|
698 |
var _this = this; |
|
|
699 |
|
|
|
700 |
//Si l'index de lecture des vidéos en mode sans utilisateur excède le nombre maximal de vidéos, il est remis à 0 pour tourner en boucle. |
|
|
701 |
if(this.currentRandomVideoIdx > this.config.imagesToShow) |
|
|
702 |
{ |
|
|
703 |
this.currentRandomVideoIdx = 0; |
|
|
704 |
} |
|
|
705 |
|
|
|
706 |
//Le snapshot sur lequel on doit zoomé a pour id le tableau de lecture aléatoire à l'index de lecture. |
|
|
707 |
this.previousZoomedSN = $('#snapshotDiv-' + this.fillingIds[this.currentRandomVideoIdx]); |
|
|
708 |
this.previousId = $('img', this.previousZoomedSN).attr('id'); |
|
|
709 |
|
|
|
710 |
//On fait apparaître le snapshot avant de zoomer dessus. |
|
|
711 |
this.previousZoomedSN.fadeTo(this.config.timePrezoom, 1, function() |
|
|
712 |
{ |
|
|
713 |
_this.zoom(); |
|
|
714 |
_this.currentRandomVideoIdx++; |
|
|
715 |
}); |
|
35
|
716 |
} |
|
|
717 |
|
|
|
718 |
/* |
|
|
719 |
* Remplissage de la mosaïque en fonction du nombre d'images à afficher. |
|
52
|
720 |
* Est appelé dans le fichier : |
|
|
721 |
* mosaic > fonctions loadMosaic et manageControlEvents. |
|
35
|
722 |
*/ |
|
52
|
723 |
Mosaic.prototype.showNImages = function(n) |
|
|
724 |
{ |
|
|
725 |
//Si on bouge vers un voisin, on n'utilise pas cette fonction. |
|
|
726 |
if(this.currentlyMoving) |
|
|
727 |
{ |
|
|
728 |
return; |
|
|
729 |
} |
|
|
730 |
|
|
|
731 |
//Si il y a plus d'un snapshot à afficher, on entre dans le mode INCOMING avec en paramètre le nombre à afficher. |
|
|
732 |
if(n > 1 && n < this.config.imagesToShow) |
|
|
733 |
{ |
|
|
734 |
//On met en mode incoming avec le nombre de snapshots à afficher. |
|
|
735 |
this.currentMode = "INCOMING-" + n; |
|
|
736 |
//On dézoom. |
|
|
737 |
this.unzoom(); |
|
|
738 |
|
|
|
739 |
//On initialise les gestures de recherche. |
|
|
740 |
for(var i = 0 ; i < this.config.imagesToShow ; i++) |
|
|
741 |
{ |
|
|
742 |
this.currentSearchGesture[i] = ''; |
|
|
743 |
} |
|
|
744 |
|
|
|
745 |
//On enlève les notifications. |
|
|
746 |
this.removeNotifications(); |
|
|
747 |
//On annule les recherches. |
|
|
748 |
this.isMosaicFiltered = false; |
|
|
749 |
this.isCurrentlyInASearchByGesture = false; |
|
|
750 |
//On masque les pointeurs. |
|
|
751 |
$('#mainPointer').fadeTo(this.config.timePrezoom, 0); |
|
|
752 |
$('#secondPointer').fadeTo(this.config.timePrezoom, 0); |
|
|
753 |
//On enlève le spinner. |
|
|
754 |
$('#spinner').remove(); |
|
|
755 |
//On déselectionne tous les voisins. |
|
|
756 |
this.deselectAllNeighbours(); |
|
|
757 |
//On enlève tous les prézooms en cours. |
|
|
758 |
$('.prezoomContainers').remove(); |
|
|
759 |
} |
|
|
760 |
|
|
|
761 |
//Si on doit afficher la mosaique complète. |
|
|
762 |
if(n >= this.config.imagesToShow) |
|
|
763 |
{ |
|
|
764 |
//Si on est en mode sans utilisateur ou bien en mode d'utilisateur approchant. |
|
|
765 |
if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING-") > -1) |
|
|
766 |
{ |
|
|
767 |
//Si on est en intéractions Kinect. |
|
|
768 |
if(!this.config.mouseInteractions) |
|
|
769 |
{ |
|
|
770 |
//On met le mode à jour. |
|
|
771 |
this.currentMode = "INCOMING-20"; |
|
|
772 |
//On dézoom. |
|
|
773 |
this.unzoom(); |
|
|
774 |
} |
|
|
775 |
|
|
|
776 |
//On passe en mode mosaique. |
|
|
777 |
this.currentMode = "MOSAIC"; |
|
|
778 |
//On enlève les notifications, et on met les notifications de sélection et de recherche. |
|
|
779 |
this.removeNotifications(); |
|
|
780 |
this.mosaicSelectionAndSearch(); |
|
|
781 |
//On retarde le mécanisme de redémarrage. |
|
|
782 |
clearTimeout(this.nouserTimeout); |
|
|
783 |
} |
|
|
784 |
} |
|
|
785 |
|
|
|
786 |
//Pour les snapshots à afficher. |
|
|
787 |
for(var i = 0 ; i < n ; i++) |
|
|
788 |
{ |
|
|
789 |
//Si les snapshots ne sont pas affichés. |
|
|
790 |
if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') < 1) |
|
|
791 |
{ |
|
|
792 |
//On les fait apparaître. |
|
|
793 |
$('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config.timeFilling, '1'); |
|
|
794 |
} |
|
|
795 |
} |
|
|
796 |
//Pour ceux à masquer. |
|
|
797 |
for(var i = n ; i < this.config.imagesToShow ; i++) |
|
|
798 |
{ |
|
|
799 |
//Si les snapshots ne sont pas masqués et qu'il ne s'agit pas du dernier snapshot en lecture aléatoire (mode NO-USER). |
|
|
800 |
if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') > 0 && this.fillingIds[i] != this.currentRandomVideoIdx) |
|
|
801 |
{ |
|
|
802 |
//On les masque. |
|
|
803 |
$('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config.timeFilling, '0'); |
|
|
804 |
} |
|
|
805 |
} |
|
|
806 |
} |
|
|
807 |
|
|
|
808 |
/* |
|
|
809 |
* Gère les événements de contrôle dans la mosaïque. |
|
|
810 |
* Est appelé dans le fichier : |
|
|
811 |
* client > fonction processMsg. |
|
|
812 |
*/ |
|
|
813 |
Mosaic.prototype.manageControlEvents = function(event) |
|
35
|
814 |
{ |
|
52
|
815 |
var _this = this; |
|
|
816 |
|
|
|
817 |
if(typeof event === 'undefined') |
|
|
818 |
{ |
|
|
819 |
return; |
|
|
820 |
} |
|
|
821 |
|
|
|
822 |
var gestureReceived = ''; |
|
|
823 |
|
|
|
824 |
//Si l'utilisateur arrive et qu'on a la préphase activée. |
|
|
825 |
if(event.indexOf("INCOMING-") != -1 && this.config.noUserModeEnabled) |
|
|
826 |
{ |
|
|
827 |
//Si on peut démarrer. |
|
|
828 |
if(this.canStart) |
|
|
829 |
{ |
|
|
830 |
//Si on veut afficher plus de snapshots que disponibles, on affiche le maximum. |
|
|
831 |
if(this.snapshotsToShow > this.config.imagesToShow) |
|
|
832 |
{ |
|
|
833 |
this.snapshotsToShow = this.config.imagesToShow; |
|
|
834 |
} |
|
|
835 |
else |
|
|
836 |
{ |
|
|
837 |
//On récupère le nombre de snapshots à afficher. |
|
|
838 |
var params = event.split('-'); |
|
|
839 |
this.snapshotsToShow = params[1]; |
|
|
840 |
} |
|
|
841 |
|
|
|
842 |
//Si la position de l'utilisateur a changé. |
|
|
843 |
if(event != this.lastIncomingMessage) |
|
|
844 |
{ |
|
|
845 |
//On la met à jour et on affiche la mosaique en conséquence. |
|
|
846 |
this.lastIncomingMessage = event; |
|
|
847 |
this.showNImages(this.snapshotsToShow); |
|
|
848 |
} |
|
|
849 |
} |
|
|
850 |
|
|
|
851 |
//On retarde le mécanisme de redémarrage. |
|
|
852 |
clearTimeout(this.nouserTimeout); |
|
|
853 |
|
|
|
854 |
//Après un délai d'absence de l'utilisateur on redémarre. |
|
|
855 |
this.nouserTimeout = setTimeout(function() |
|
|
856 |
{ |
|
58
|
857 |
// window.location.reload(); |
|
52
|
858 |
}, this.config.timeoutNouser); |
|
|
859 |
} |
|
|
860 |
//S'il n'y a qu'un snapshot à afficher et qu'on est en préphase, on redémarre. |
|
|
861 |
else if((event == "NO-USER" || event == "INCOMING-0" || event == "INCOMING-1") && this.config.noUserModeEnabled) |
|
|
862 |
{ |
|
58
|
863 |
// window.location.reload(); |
|
52
|
864 |
} |
|
|
865 |
//Si on a fait un swipe. |
|
|
866 |
else if(event.indexOf("SWIPE") != -1) |
|
|
867 |
{ |
|
|
868 |
//Si le player est près et qu'on n'est pas en train de faire un swipe. |
|
|
869 |
if(this.player && this.player.widgets && this.playerIsReady && !this.isSwipe) |
|
|
870 |
{ |
|
|
871 |
//On est en train de faire un swipe. |
|
|
872 |
this.isSwipe = true; |
|
|
873 |
|
|
|
874 |
//Si on est en mode de recherche, que la mosaique est filtrée et qu'on est arrivé au dernier marqueur. |
|
|
875 |
if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture[this.centerId])) |
|
|
876 |
{ |
|
|
877 |
//On passe à la prochaine vidéo qui contient des résultats. |
|
|
878 |
this.playNextVideo(); |
|
|
879 |
} |
|
|
880 |
|
|
|
881 |
//On spécifie s'il s'agit d'un swipe left ou right. |
|
|
882 |
var swipeType = ((event.indexOf("LEFT") != -1) ? 'left' : 'right'); |
|
|
883 |
var isSwipeLeft = ((event.indexOf("LEFT") != -1) ? true : false); |
|
|
884 |
|
|
|
885 |
//On passe au marqueur suivant/précédent en fonction du type de swipe. |
|
|
886 |
this.player.widgets[0].switchToMarker(isSwipeLeft, this.currentSearchGesture[this.centerId]); |
|
|
887 |
//Si on est en mode vidéo. |
|
|
888 |
if(this.currentMode == 'VIDEO') |
|
|
889 |
{ |
|
|
890 |
//On affiche la notification. |
|
|
891 |
this.removeNotifications(); |
|
|
892 |
this.videoSwipe(swipeType); |
|
|
893 |
} |
|
|
894 |
//Si on est en mode recherche dans une vidéo et qu'on n'a pas de gesture de recherche. |
|
|
895 |
else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId] == '') |
|
|
896 |
{ |
|
|
897 |
//On affiche la notification. |
|
|
898 |
this.removeNotifications(); |
|
|
899 |
this.searchSearchAndSwipe(swipeType); |
|
|
900 |
} |
|
|
901 |
//Si on est en mode recherche dans une vidéo et qu'on a une gesture de recherche. |
|
|
902 |
else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId] != '') |
|
|
903 |
{ |
|
|
904 |
//On affiche la notification. |
|
|
905 |
this.removeNotifications(); |
|
|
906 |
this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', swipeType); |
|
|
907 |
} |
|
|
908 |
|
|
|
909 |
//On le fait disparaitre au bout d'un certain temps. |
|
|
910 |
this.notifySwipeTimeout = setTimeout(function() |
|
|
911 |
{ |
|
|
912 |
_this.isSwipe = false; |
|
|
913 |
_this.removeNotifications(); |
|
|
914 |
|
|
|
915 |
//Si on est en mode de recherche dans une vidéo et qu'aucune gesture n'est recherchée. |
|
|
916 |
if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '') |
|
|
917 |
{ |
|
|
918 |
_this.searchSearch(); |
|
|
919 |
} |
|
|
920 |
//Si on est en mode de recherche dans une vidéo et qu'on a une recherche par gesture. |
|
|
921 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '') |
|
|
922 |
{ |
|
|
923 |
_this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid'); |
|
|
924 |
} |
|
|
925 |
|
|
|
926 |
}, this.config.timeoutNotifySwipe); |
|
|
927 |
} |
|
|
928 |
} |
|
|
929 |
//Si on reçoit l'instruction correspondant à une des quatre gestures de recherche corporelle. |
|
|
930 |
else if(event.indexOf("BEND") != -1 || event.indexOf('KNEE-UP') != -1 || event.indexOf('FALL') != -1 || event.indexOf('JUMP') != -1) |
|
|
931 |
{ |
|
|
932 |
//On la met en minuscule. |
|
|
933 |
gestureReceived = event.toLowerCase(); |
|
|
934 |
//On met à jour la gesture recherchée. |
|
58
|
935 |
this.currentSearchGesture[this.centerId] = gestureReceived; |
|
52
|
936 |
} |
|
|
937 |
//Si on a effectué un hello, qu'on peut notifier l'aide et que les deux mains ne sont pas dans la zone de recherche. |
|
|
938 |
else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere) |
|
|
939 |
{ |
|
|
940 |
//On affiche différentes aides en fonction de si on se trouve dans une vidéo ou non. |
|
|
941 |
if(this.currentMode == 'SEARCH') |
|
|
942 |
{ |
|
|
943 |
this.notifyHelp(false); |
|
|
944 |
} |
|
|
945 |
else if(this.currentMode == 'FILTER') |
|
|
946 |
{ |
|
|
947 |
this.notifyHelp(true); |
|
|
948 |
} |
|
|
949 |
} |
|
|
950 |
|
|
|
951 |
//Si on a reçu une gesture. |
|
|
952 |
if(gestureReceived != '') |
|
|
953 |
{ |
|
|
954 |
//Si on est en mode recherche et que le player est prêt. |
|
|
955 |
if(this.currentMode == "SEARCH" && this.playerIsReady) |
|
|
956 |
{ |
|
|
957 |
//On recherche dans la vidéo. |
|
|
958 |
this.player.widgets[0].searchByGesture(gestureReceived); |
|
|
959 |
this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture; |
|
|
960 |
//On notifie. |
|
|
961 |
this.removeNotifications(); |
|
|
962 |
this.searchGesture(gestureReceived, 'valid'); |
|
|
963 |
} |
|
|
964 |
//Si on est dans un filtrage. |
|
|
965 |
else if(this.currentMode == "FILTER") |
|
|
966 |
{ |
|
|
967 |
if(this.isMosaicFiltered) |
|
|
968 |
{ |
|
|
969 |
//On notifie et on filtre. |
|
|
970 |
this.removeNotifications(); |
|
|
971 |
this.filterGesture(gestureReceived, 'valid'); |
|
|
972 |
this.searchFilter(gestureReceived); |
|
|
973 |
} |
|
|
974 |
} |
|
|
975 |
|
|
|
976 |
//Si l'aide est affichée, on l'enlève. |
|
|
977 |
if(this.helpDisplayed) |
|
|
978 |
{ |
|
|
979 |
this.removeHelp(); |
|
|
980 |
} |
|
|
981 |
} |
|
|
982 |
} |
|
|
983 |
|
|
|
984 |
/* |
|
|
985 |
* Fonction qui s'exécute lorsque le player a chargé. |
|
|
986 |
* Est appelé dans le fichier : |
|
|
987 |
* mosaic > fonction loadPlayer. |
|
|
988 |
*/ |
|
|
989 |
Mosaic.prototype.onPlayerLoad = function() |
|
|
990 |
{ |
|
|
991 |
var _this = this; |
|
|
992 |
|
|
|
993 |
if(this.currentMode == 'NO-USER') |
|
44
|
994 |
{ |
|
52
|
995 |
//On peut s'approcher de la kinect. |
|
|
996 |
this.canStart = true; |
|
44
|
997 |
} |
|
|
998 |
|
|
52
|
999 |
//Lorsque le player est en pause (par exemple lorsque le curseur arrive à la fin de la timeline). |
|
|
1000 |
if(this.player.popcorn) |
|
35
|
1001 |
{ |
|
79
|
1002 |
// this.player.popcorn.listen('pause', function() |
|
|
1003 |
this.player.popcorn.listen('ended', function() |
|
47
|
1004 |
{ |
|
52
|
1005 |
//Si la pause est naturelle (fin de la timeline, dézoom, déplacement vers un voisin). |
|
|
1006 |
if(!_this.userPaused) |
|
|
1007 |
{ |
|
|
1008 |
//Si c'est en mode sans utilisateur. |
|
|
1009 |
if(_this.currentMode == 'NO-USER') |
|
|
1010 |
{ |
|
|
1011 |
//On dézoome. |
|
|
1012 |
_this.unzoom(); |
|
|
1013 |
} |
|
|
1014 |
//Sinon, si ce n'est pas causé par un déplacement ou un dézoom. |
|
|
1015 |
else if(!_this.currentlyMoving && !_this.currentlyUnzooming) |
|
|
1016 |
{ |
|
|
1017 |
//Si on est en mode timeline et qu'on est en pause, c'est probablement que l'user a placé le curseur à la fin. |
|
|
1018 |
if(_this.currentMode != 'TIMELINE') |
|
|
1019 |
{ |
|
|
1020 |
_this.playNextVideo(); |
|
|
1021 |
} |
|
|
1022 |
} |
|
|
1023 |
} |
|
|
1024 |
}); |
|
47
|
1025 |
|
|
52
|
1026 |
//Si les marqueurs ont été chargés. |
|
|
1027 |
this.player.popcorn.on("markersready", function() |
|
|
1028 |
{ |
|
|
1029 |
_this.onMarkersReady(); |
|
|
1030 |
}); |
|
79
|
1031 |
|
|
|
1032 |
//On indique à la mosaïque qu'on est en train de lire. |
|
|
1033 |
this.player.popcorn.on("timeupdate", function() |
|
|
1034 |
{ |
|
|
1035 |
_this.isVideoReading = true; |
|
|
1036 |
}) |
|
44
|
1037 |
} |
|
52
|
1038 |
} |
|
|
1039 |
|
|
|
1040 |
/* |
|
|
1041 |
* Fonction qui s'exécute lorsque les marqueurs d'une video on été placés. |
|
|
1042 |
* Est appelé dans le fichier : |
|
|
1043 |
* mosaic > fonction onPlayerLoad. |
|
|
1044 |
*/ |
|
|
1045 |
Mosaic.prototype.onMarkersReady = function() |
|
|
1046 |
{ |
|
|
1047 |
var _this = this; |
|
|
1048 |
|
|
|
1049 |
//Le player est prêt. |
|
|
1050 |
this.playerIsReady = true; |
|
|
1051 |
|
|
|
1052 |
if(this.player.widgets[0]) |
|
44
|
1053 |
{ |
|
52
|
1054 |
//On spécifie à la timeline dans quel mode d'intéraction on est. |
|
|
1055 |
this.player.widgets[0].setMouseInteractions(this.config.mouseInteractions); |
|
|
1056 |
//Idem pour la langue. |
|
|
1057 |
if(this.gesturesText.length > 0) |
|
44
|
1058 |
{ |
|
52
|
1059 |
this.player.widgets[0].setLang(this.gesturesText); |
|
44
|
1060 |
} |
|
35
|
1061 |
} |
|
|
1062 |
|
|
52
|
1063 |
//Si on est en mode video ou recherche ou timeline. |
|
|
1064 |
if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH' || this.currentMode == 'TIMELINE') |
|
|
1065 |
{ |
|
|
1066 |
//On peut faire des swipes. |
|
|
1067 |
this.canSwipe = true; |
|
|
1068 |
} |
|
|
1069 |
|
|
|
1070 |
//Si aucune recherche par gesture n'est effectuée. |
|
|
1071 |
if(this.currentSearchGesture[this.centerId] == '') |
|
35
|
1072 |
{ |
|
52
|
1073 |
//On enlève le filtre. |
|
|
1074 |
this.removeFilter(); |
|
|
1075 |
} |
|
|
1076 |
//Sinon. |
|
|
1077 |
else |
|
|
1078 |
{ |
|
|
1079 |
//On entre en mode recherche dans une vidéo. |
|
|
1080 |
this.currentMode = 'SEARCH'; |
|
|
1081 |
//On recherche la gesture. |
|
|
1082 |
this.player.widgets[0].searchByGesture(this.currentSearchGesture[this.centerId]); |
|
|
1083 |
this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture; |
|
|
1084 |
|
|
|
1085 |
//On va au premier marqueur trouvé. |
|
|
1086 |
if(this.timeToGoAt[this.centerId] === 0 && this.player.widgets[0].atLeastOneSearchMarker(this.currentSearchGesture[this.centerId])) |
|
35
|
1087 |
{ |
|
52
|
1088 |
this.player.widgets[0].goToFirstSearchedMarker(this.currentSearchGesture[this.centerId]); |
|
35
|
1089 |
} |
|
52
|
1090 |
//Si aucun marqueur n'est trouvé. |
|
|
1091 |
else |
|
35
|
1092 |
{ |
|
52
|
1093 |
//On va juste là où on était la dernière fois qu'on a joué la vidéo. |
|
|
1094 |
this.player.popcorn.currentTime(this.timeToGoAt[this.centerId]); |
|
44
|
1095 |
} |
|
|
1096 |
} |
|
35
|
1097 |
} |
|
|
1098 |
|
|
|
1099 |
/* |
|
52
|
1100 |
* Chargement du player basé sur le metadataplayer. |
|
|
1101 |
* Est appelé dans les fichiers : |
|
|
1102 |
* neighbours > fonction moveToNeighbour. |
|
|
1103 |
* zoomInteractions > zoom. |
|
35
|
1104 |
*/ |
|
52
|
1105 |
Mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft, timeToGo) |
|
35
|
1106 |
{ |
|
52
|
1107 |
var _this = this; |
|
|
1108 |
|
|
|
1109 |
//On configure les options de lancement. |
|
|
1110 |
IriSP.libFiles.defaultDir = "../lib/"; |
|
|
1111 |
IriSP.widgetsDir = "./player/metadataplayer/" |
|
|
1112 |
|
|
|
1113 |
var videoToPlay = this.videos[this.centerId]; |
|
|
1114 |
var currentMetadata = this.urls[this.centerId]; |
|
|
1115 |
|
|
|
1116 |
var _metadata = { |
|
|
1117 |
url: currentMetadata, |
|
|
1118 |
format: 'ldt' |
|
|
1119 |
}; |
|
|
1120 |
|
|
79
|
1121 |
var loadedWidgets; |
|
|
1122 |
|
|
|
1123 |
if(this.isTablet) |
|
|
1124 |
{ |
|
|
1125 |
loadedWidgets = |
|
|
1126 |
[ |
|
|
1127 |
{ |
|
|
1128 |
type: "Timeline" |
|
|
1129 |
}, |
|
|
1130 |
{ |
|
|
1131 |
type: "TabletPlayButton" |
|
|
1132 |
} |
|
|
1133 |
]; |
|
|
1134 |
} |
|
|
1135 |
else |
|
|
1136 |
{ |
|
|
1137 |
loadedWidgets = |
|
|
1138 |
[ |
|
|
1139 |
{ |
|
|
1140 |
type: "Timeline" |
|
|
1141 |
} |
|
|
1142 |
]; |
|
|
1143 |
} |
|
|
1144 |
|
|
52
|
1145 |
var _config = { |
|
|
1146 |
gui: { |
|
|
1147 |
zoomTop: zoomTop - this.marginWidth*2, |
|
|
1148 |
zoomLeft: zoomLeft, |
|
|
1149 |
width: newSnWidth, |
|
|
1150 |
height: newSnHeight, |
|
|
1151 |
container: 'LdtPlayer', |
|
|
1152 |
default_options: { |
|
|
1153 |
metadata: _metadata |
|
|
1154 |
}, |
|
|
1155 |
css:'./player/metadataplayer/LdtPlayer-core.css', |
|
79
|
1156 |
widgets: loadedWidgets |
|
52
|
1157 |
}, |
|
|
1158 |
player:{ |
|
|
1159 |
type: 'html5', // player type |
|
77
|
1160 |
// type: 'jwplayer', // player type |
|
52
|
1161 |
video: videoToPlay, |
|
|
1162 |
live: true, |
|
|
1163 |
height: newSnHeight, |
|
|
1164 |
width: newSnWidth, |
|
|
1165 |
autostart: true |
|
79
|
1166 |
}, |
|
|
1167 |
isTablet: this.isTablet |
|
52
|
1168 |
}; |
|
|
1169 |
|
|
|
1170 |
//On positionne le player. |
|
|
1171 |
$('.LdtPlayer').css( |
|
30
|
1172 |
{ |
|
52
|
1173 |
position: 'absolute', |
|
|
1174 |
'background-color': '#000000', |
|
|
1175 |
top: newZoomTop, |
|
77
|
1176 |
left: newZoomLeft, |
|
|
1177 |
'z-index': 500 |
|
52
|
1178 |
}); |
|
|
1179 |
|
|
|
1180 |
//On démarre le player. |
|
|
1181 |
this.player = null; |
|
|
1182 |
|
|
|
1183 |
this.player = new IriSP.Metadataplayer(_config, _metadata); |
|
|
1184 |
|
|
|
1185 |
this.player.onLoad(function() |
|
30
|
1186 |
{ |
|
52
|
1187 |
_this.onPlayerLoad(); |
|
|
1188 |
}); |
|
32
|
1189 |
} |
|
|
1190 |
|
|
|
1191 |
/* |
|
|
1192 |
* Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
|
52
|
1193 |
* Est appelé dans le fichier : |
|
|
1194 |
* mosaic > fonction loadParameters. |
|
32
|
1195 |
*/ |
|
52
|
1196 |
Mosaic.prototype.loadFromJson = function(path) |
|
32
|
1197 |
{ |
|
52
|
1198 |
var _this = this; |
|
|
1199 |
var i = 0; |
|
|
1200 |
|
|
|
1201 |
//On ouvre le fichier contenant les vidéos et les adresses des métadonnées. |
|
|
1202 |
$.getJSON(path, function(data) |
|
|
1203 |
{ |
|
|
1204 |
$.each(data, function(key, val) |
|
|
1205 |
{ |
|
|
1206 |
$.each(val, function(key_video, val_video) |
|
|
1207 |
{ |
|
|
1208 |
//On extrait les métadonnées. |
|
|
1209 |
$.getJSON(val_video.metadata, function(meta) |
|
|
1210 |
{ |
|
|
1211 |
//Si on est en chargement local. |
|
|
1212 |
if(_this.config.local) |
|
|
1213 |
{ |
|
|
1214 |
//On cherche les vidéos dans les métadonnées. |
|
|
1215 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4')); |
|
|
1216 |
} |
|
|
1217 |
//Si on est en chargement en ligne. |
|
|
1218 |
else |
|
|
1219 |
{ |
|
|
1220 |
//On met l'adresse des videos en ligne. |
|
|
1221 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
|
1222 |
} |
|
|
1223 |
}); |
|
|
1224 |
|
|
|
1225 |
//On affecte les images et métadonnées. |
|
|
1226 |
_this.imgs[_this.ids[i]] = val_video.snapshot; |
|
|
1227 |
_this.urls[_this.ids[i]] = val_video.metadata; |
|
|
1228 |
//Au départ, on commence à 0 ms dans les vidéos. |
|
|
1229 |
_this.timeToGoAt[_this.ids[i]] = 0; |
|
|
1230 |
i++; |
|
|
1231 |
}); |
|
|
1232 |
}); |
|
|
1233 |
|
|
|
1234 |
//On charge la mosaique. |
|
|
1235 |
_this.loadMosaic(); |
|
|
1236 |
}); |
|
32
|
1237 |
} |
|
|
1238 |
|
|
|
1239 |
/* |
|
52
|
1240 |
* Affecte une vidéo au tableau des vidéos selon son id. |
|
|
1241 |
* Est appelé dans le fichier : |
|
|
1242 |
* mosaic > fonction loadFromJson. |
|
32
|
1243 |
*/ |
|
52
|
1244 |
Mosaic.prototype.affectVideoById = function(metadata_id, video) |
|
32
|
1245 |
{ |
|
52
|
1246 |
for (i = 0 ; i < this.urls.length ; i++) |
|
|
1247 |
{ |
|
|
1248 |
if(this.urls[i] == metadata_id) |
|
|
1249 |
{ |
|
|
1250 |
this.videos[i] = video; |
|
|
1251 |
break; |
|
|
1252 |
} |
|
|
1253 |
} |
|
33
|
1254 |
} |
|
|
1255 |
|
|
|
1256 |
/* |
|
52
|
1257 |
* Affiche la date actuelle pour l'affichage de messages dans la console. |
|
|
1258 |
* Est appelé dans chaque console.log() où on veut afficher la date à laquelle l'instruction est exécutée. |
|
35
|
1259 |
*/ |
|
52
|
1260 |
Mosaic.prototype.date = function() |
|
44
|
1261 |
{ |
|
|
1262 |
var date, h, min, s; |
|
|
1263 |
date = new Date(); |
|
|
1264 |
h = date.getHours(); |
|
|
1265 |
min = date.getMinutes(); |
|
|
1266 |
s = date.getSeconds(); |
|
|
1267 |
if (h < 10) |
|
|
1268 |
h = "0" + h; |
|
|
1269 |
if (min < 10) |
|
|
1270 |
min = "0" + min; |
|
|
1271 |
if (s < 10) |
|
|
1272 |
s = "0" + s; |
|
|
1273 |
return (h + ":" + min + ":" + s); |
|
|
1274 |
}; |