|
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. |
|
|
24 |
*/ |
|
35
|
25 |
function mosaic(config, default_conf) |
|
30
|
26 |
{ |
|
44
|
27 |
//Interactions souris/kinect. |
|
|
28 |
this.mouseInteractions = false; |
|
|
29 |
//Interactions avec/sans préphase. |
|
|
30 |
this.prephaseEnabled = true; |
|
|
31 |
|
|
|
32 |
this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "pendulum", "knee-up", "right-angle", "wave", "slow", "hello", "no-motion", "wheel", "contact", "run"]; |
|
|
33 |
|
|
35
|
34 |
//Chemin du fichier de configuration. |
|
|
35 |
this.config_path = config; |
|
|
36 |
//Configuration par défaut en cas de valeur erronnée. |
|
|
37 |
this.default_config = default_conf; |
|
44
|
38 |
this.config = new Object(); |
|
35
|
39 |
//Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
|
|
40 |
this.videos = []; |
|
|
41 |
this.urls = []; |
|
44
|
42 |
this.sources = []; |
|
35
|
43 |
this.imgs = []; |
|
44
|
44 |
this.opacities = []; |
|
|
45 |
this.timeToGoAt = []; |
|
35
|
46 |
this.ids = []; |
|
|
47 |
this.fillingIds = []; |
|
|
48 |
this.currentRandomVideoIdx = 0; |
|
44
|
49 |
|
|
|
50 |
//Dernières positions des pointeurs. |
|
|
51 |
this.mainPointerLastX; |
|
|
52 |
this.mainPointerLastY; |
|
|
53 |
this.secondPointerLastX; |
|
|
54 |
this.secondPointerLastY; |
|
|
55 |
//Dernières positions avant le lancement de la fonction d'idle. |
|
|
56 |
this.mainPointerIdleStartX; |
|
|
57 |
this.mainPointerIdleStartY; |
|
|
58 |
this.secondPointerIdleStartX; |
|
|
59 |
this.secondPointerIdleStartY; |
|
|
60 |
|
|
35
|
61 |
//Dimensions de la mosaïque en pixels. |
|
|
62 |
this.width; |
|
44
|
63 |
this.height; |
|
35
|
64 |
//Dimensions d'un snapshot en pixels. |
|
|
65 |
this.snapshotWidth; |
|
44
|
66 |
this.snapshotHeight; |
|
35
|
67 |
//Espacement entre les snapshots en pixels. |
|
|
68 |
this.marginWidth; |
|
44
|
69 |
|
|
35
|
70 |
//Booléens permettant ou non certaines intéractions selon le contexte. |
|
|
71 |
this.zoomed; |
|
|
72 |
this.fullscreen; |
|
|
73 |
this.canMoveToNeighbour; |
|
44
|
74 |
this.mainPointerExitBorder; |
|
|
75 |
this.secondPointerExitBorder; |
|
|
76 |
this.isMainPointerDisplayed; |
|
|
77 |
this.isSecondPointerDisplayed; |
|
35
|
78 |
this.helpDisplayed; |
|
44
|
79 |
//Indique si l'utilisateur a manuellement pausé la vidéo. |
|
|
80 |
this.userPaused; |
|
|
81 |
//Indique si on est en train de se déplacer vers un voisin. |
|
|
82 |
this.currentlyMoving; |
|
|
83 |
//Indique si on est en train de dézoomer vers la mosaïque. |
|
|
84 |
this.currentlyUnzooming; |
|
|
85 |
//Indique si on peut s'approcher de kinect. |
|
|
86 |
this.canStart; |
|
|
87 |
//Indique si on est actuellement sur un snapshot. |
|
|
88 |
this.isOnASnapshot; |
|
|
89 |
//Indique si l'idle des pointeurs est disponible (deux mains détectées). |
|
|
90 |
this.pointersIdleAvailable; |
|
|
91 |
//Indique si le timeout pour l'idle des pointeurs à besoin d'être lancé. |
|
|
92 |
this.pointersIdleNeedLaunch; |
|
|
93 |
//Indique si les deux mains sont là. |
|
|
94 |
this.areBothPointersHere; |
|
|
95 |
//Indique si le timeout pour la détection de deux pointeurs a été lancé. |
|
|
96 |
this.areBothPointersTimeoutLaunched; |
|
|
97 |
//Indique si la mosaïque a été filtrée. |
|
|
98 |
this.isMosaicFiltered; |
|
|
99 |
//Indique si on est actuellement dans une recherche par gesture. |
|
|
100 |
this.isCurrentlyInASearchByGesture; |
|
|
101 |
//Indique si un pointeur est déjà sur une notification de recherche par gesture. |
|
|
102 |
this.alreadyOnNotification; |
|
|
103 |
//Si on a fait un swipe. |
|
|
104 |
this.isSwipe; |
|
|
105 |
//On peut swiper. |
|
|
106 |
this.canSwipe; |
|
|
107 |
//On passe vers une autre video automatiquement à la fin d'une lecture. |
|
|
108 |
this.autoMove; |
|
|
109 |
//Si l'utilisateur a demandé à sélectionner la TL. |
|
|
110 |
this.isTLRequested; |
|
|
111 |
//Le pointeur gauche a sélectionné la TL. |
|
|
112 |
this.isTLSelectedBySecondPointer; |
|
|
113 |
//Le pointeur droit a sélectionné la TL. |
|
|
114 |
this.isTLSelectedByMainPointer; |
|
|
115 |
//On peut afficher l'aide. |
|
|
116 |
this.canNotifyHelp; |
|
|
117 |
//Indique si la mosaique est en train d'être filtrée. |
|
|
118 |
this.isMosaicFiltering; |
|
|
119 |
this.arrowLeftLoading = false; |
|
|
120 |
this.arrowRightLoading = false; |
|
|
121 |
this.arrowUpLoading = false; |
|
|
122 |
this.arrowDownLoading = false; |
|
|
123 |
//On est dans une recherche par courbes. |
|
|
124 |
this.isSearchByCurvesOn; |
|
|
125 |
this.canDrawNextCurve = false; |
|
|
126 |
|
|
|
127 |
//Timeout (attente) pour le zoom après un préZoom. |
|
|
128 |
this.zoomTimeout; |
|
|
129 |
//Timeout (attente) pour le passage vers un voisin. |
|
|
130 |
this.moveToNeighbourTimeout; |
|
|
131 |
this.mainPointerExitBorderTimeout; |
|
|
132 |
this.secondPointerExitBorderTimeout; |
|
|
133 |
//Idle time pour les pointeurs afin d'informer le front qu'on souhaite faire une recherche. |
|
|
134 |
this.pointersSearchIdleTimeout; |
|
|
135 |
//Vérifie toutes les N ms que les deux pointeurs sont détectés. |
|
|
136 |
this.areBothPointersHereTimeout; |
|
|
137 |
//Délai de suppression d'une notification de recherche par gesture. |
|
|
138 |
this.removeNotificationByGestureTimeout; |
|
|
139 |
//Délai de suppression d'une notification de recherche par gesture infructueuse. |
|
|
140 |
this.removeFailedNotificationByGestureTimeout; |
|
|
141 |
//Délai avant la suppression de notification swipe. |
|
|
142 |
this.notifySwipeTimeout; |
|
|
143 |
//Délai pour la sélection de la TL. |
|
|
144 |
this.selectTLTimeout; |
|
|
145 |
//Délai pour slider sur la TL. |
|
|
146 |
this.canSlideInTLTimeout; |
|
|
147 |
//Délai pour afficher l'aide. |
|
|
148 |
this.canNotifyHelpTimeout; |
|
|
149 |
this.arrowLeftTimeout; |
|
|
150 |
this.arrowRightTimeout; |
|
|
151 |
this.arrowUpTimeout; |
|
|
152 |
this.arrowDownTimeout; |
|
|
153 |
|
|
|
154 |
this.arrowSpinnerTimeout; |
|
|
155 |
this.nouserTimeout; |
|
|
156 |
this.nextDrawCurveTimeout; |
|
|
157 |
|
|
|
158 |
//Dernier message INCOMING (pour éviter d'effectuer n fois la même action. |
|
|
159 |
this.lastIncomingMessage; |
|
35
|
160 |
|
|
|
161 |
//Type de marqueur recherché dans la mosaïque (en mode filter). |
|
|
162 |
this.filterSearchedType = ""; |
|
44
|
163 |
|
|
35
|
164 |
//Mode actuel. |
|
44
|
165 |
this.currentMode = "NO-USER"; |
|
35
|
166 |
//Snapshot sur lequel on a zoomé. |
|
44
|
167 |
this.previousZoomedSN = null; |
|
35
|
168 |
//Son ID. |
|
44
|
169 |
this.previousId; |
|
|
170 |
//Dernier snapshot prézoomé non null. |
|
|
171 |
this.lastNonNullSN = null; |
|
35
|
172 |
//Largeur de la marge pour le centrage vertical de la mosaïque. |
|
|
173 |
this.MPTop_margin; |
|
44
|
174 |
this.top_margin; |
|
|
175 |
|
|
|
176 |
//Gesture actuellement cherchée. |
|
|
177 |
this.currentSearchGesture; |
|
|
178 |
|
|
35
|
179 |
//Mosaïque locale. |
|
44
|
180 |
this.localMos; |
|
35
|
181 |
//Position des voisins lors d'un zoom. |
|
44
|
182 |
this.neighboursIds = []; |
|
35
|
183 |
//ID du snapshot du milieu lors d'un zoom. |
|
|
184 |
this.centerId; |
|
|
185 |
|
|
44
|
186 |
//Voisins sélectionnés par les pointeurs. |
|
|
187 |
this.mainPointerNeighbourSelectedId = null; |
|
|
188 |
this.secondPointerNeighbourSelectedId = null; |
|
|
189 |
|
|
35
|
190 |
//Snapshots a afficher. |
|
|
191 |
this.snapshotsToShow = 1; |
|
|
192 |
|
|
|
193 |
//Lecteur. |
|
|
194 |
this.player; |
|
44
|
195 |
//Si le lecteur est prêt. |
|
|
196 |
this.playerIsReady; |
|
|
197 |
|
|
35
|
198 |
//Annotations (pour les marqueurs los d'un filtrage). |
|
|
199 |
this.annotations = []; |
|
|
200 |
|
|
44
|
201 |
//Client websocket pour recevoir les notifications du Middleware. |
|
|
202 |
this.client; |
|
|
203 |
|
|
35
|
204 |
//Coordonnées et dimensions d'un snapshot zoomé. |
|
|
205 |
this.snTop = 0; |
|
|
206 |
this.snLeft = 0; |
|
|
207 |
this.snWidth = 0; |
|
|
208 |
this.snHeight = 0; |
|
|
209 |
|
|
|
210 |
this.searchCanvas; |
|
|
211 |
//Position actuelle de la vidéo zoomée. |
|
|
212 |
this.notifyTopVideo; |
|
|
213 |
this.notifyLeftVideo; |
|
|
214 |
this.loadParameters(this.config_path); |
|
30
|
215 |
} |
|
|
216 |
|
|
|
217 |
/* |
|
|
218 |
* Méthode d'affichage de la mosaïque. |
|
|
219 |
* Génère une matrice de imgs. |
|
|
220 |
*/ |
|
|
221 |
mosaic.prototype.createMosaic = function() |
|
|
222 |
{ |
|
44
|
223 |
// console.log('CREATE'); |
|
|
224 |
// this.currentMode = "NO-USER"; |
|
35
|
225 |
var initPanel = '<div id="initPanel"></div>'; |
|
|
226 |
var mp = $('#mainPanel'); |
|
|
227 |
mp.append(initPanel); |
|
|
228 |
$('#initPanel').css( |
|
|
229 |
{ |
|
|
230 |
background: 'transparent', |
|
|
231 |
width: mp.width(), |
|
|
232 |
height: mp.height(), |
|
|
233 |
top: mp.position().top, |
|
|
234 |
left: mp.position().left, |
|
|
235 |
'margin-top': this.MPTop_margin |
|
|
236 |
}); |
|
|
237 |
|
|
|
238 |
var len = this.config['length'], imgs = this.config['imagesToShow'], imgsTotal = this.config['imagesTotal']; |
|
|
239 |
|
|
|
240 |
//S'il s'agit d'un rectangle. |
|
|
241 |
if(imgs % len == 0) |
|
30
|
242 |
{ |
|
44
|
243 |
this.previousZoomedSN = null; |
|
|
244 |
this.previousPrezoomDiv = null; |
|
35
|
245 |
this.fullscreen = false; |
|
|
246 |
this.canMoveToNeighbour = false; |
|
44
|
247 |
this.currentlyZooming = false; |
|
|
248 |
this.currentlyUnzooming = false; |
|
35
|
249 |
this.helpDisplayed = false; |
|
44
|
250 |
this.canStart = false; |
|
|
251 |
this.isOnASnapshot = false; |
|
|
252 |
this.isMosaicFiltered = false; |
|
|
253 |
this.areBothPointersHere = false; |
|
|
254 |
this.areBothPointersTimeoutLaunched = false; |
|
|
255 |
this.isCurrentlyInASearchByGesture = false; |
|
|
256 |
this.alreadyOnNotification = false; |
|
|
257 |
this.playerIsReady = false; |
|
|
258 |
this.currentSearchGesture = ''; |
|
|
259 |
this.isMainPointerDisplayed = false; |
|
|
260 |
this.isSecondPointerDisplayed = false; |
|
|
261 |
this.isSwipe = false; |
|
|
262 |
this.canSwipe = false; |
|
|
263 |
this.autoMove = false; |
|
|
264 |
this.isTLRequested = false; |
|
|
265 |
this.isTLSelectedByMainPointer = false; |
|
|
266 |
this.isTLSelectedBySecondPointer = false; |
|
|
267 |
this.canNotifyHelp = false; |
|
|
268 |
this.isMosaicFiltering = false; |
|
|
269 |
this.isSearchByCurvesOn = false; |
|
|
270 |
|
|
|
271 |
this.lastIncomingMessage = 'INCOMING-0'; |
|
|
272 |
|
|
35
|
273 |
var str = ''; |
|
|
274 |
|
|
|
275 |
if(this.imgs.length >= imgs) |
|
|
276 |
{ |
|
|
277 |
for(var i = 0 ; i < imgs ; i++) |
|
|
278 |
{ |
|
|
279 |
//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global. |
|
|
280 |
str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>'; |
|
|
281 |
} |
|
|
282 |
} |
|
|
283 |
|
|
|
284 |
return str; |
|
|
285 |
} |
|
|
286 |
else |
|
|
287 |
{ |
|
|
288 |
alert("Le nombre d'images a afficher doit être divisible par la longueur de la mosaïque !"); |
|
|
289 |
} |
|
30
|
290 |
} |
|
|
291 |
|
|
|
292 |
/* |
|
|
293 |
* Permet de raffraichir la mosaïque. |
|
|
294 |
*/ |
|
32
|
295 |
mosaic.prototype.loadMosaic = function() |
|
30
|
296 |
{ |
|
44
|
297 |
// console.log('LOAD'); |
|
32
|
298 |
var createMosaic = this.createMosaic(); |
|
|
299 |
|
|
|
300 |
if(createMosaic == '') |
|
|
301 |
{ |
|
|
302 |
return; |
|
|
303 |
} |
|
|
304 |
|
|
|
305 |
var _this = this; |
|
|
306 |
|
|
30
|
307 |
//On affecte les chemins vers les images à la mosaïque. |
|
|
308 |
this.previousZoomedSN; |
|
|
309 |
//this.width = |
|
|
310 |
//On met à jour la mosaïque. |
|
32
|
311 |
$('#mainPanel').html(createMosaic); |
|
30
|
312 |
//On récupère la taille des bordures. |
|
|
313 |
this.marginWidth = $('.snapshotDivs').css('margin-bottom'); |
|
35
|
314 |
this.marginWidth = parseFloat(this.marginWidth)*2; |
|
30
|
315 |
//On calcule la taille des divs contenant les snapshots. |
|
|
316 |
this.width = $('#mainPanel').innerWidth(); |
|
|
317 |
//On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement. |
|
35
|
318 |
this.snapshotWidth = this.width / this.config['length'] - this.marginWidth; |
|
30
|
319 |
this.snapshotHeight = this.snapshotWidth*9/16; |
|
|
320 |
$('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2); |
|
|
321 |
|
|
|
322 |
this.height = $('#mainPanel').innerHeight(); |
|
|
323 |
//On centre verticalement la mosaïque. |
|
|
324 |
this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2; |
|
|
325 |
$('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin); |
|
32
|
326 |
|
|
44
|
327 |
//On fait coincider le background du body avec celui de la mosaïque. |
|
|
328 |
$('body').css('background-position', '0px ' + this.MPTop_margin + 'px'); |
|
|
329 |
console.log(this.MPTop_margin); |
|
33
|
330 |
|
|
44
|
331 |
/*$('.snapshotDivs').mouseover(function () |
|
32
|
332 |
{ |
|
|
333 |
//On effectue un prézoom dès qu'on va sur une image. |
|
|
334 |
_this.preZoom($(this)); |
|
44
|
335 |
});*/ |
|
35
|
336 |
|
|
|
337 |
this.addPointers(); |
|
|
338 |
|
|
|
339 |
//Si dans le metadata player _ n'est pas déclaré, on le déclare. |
|
|
340 |
if(typeof _ !== "undefined" && typeof IriSP._ === "undefined") |
|
|
341 |
{ |
|
|
342 |
IriSP._ = _; |
|
|
343 |
} |
|
|
344 |
|
|
|
345 |
if(typeof $ !== "undefined" && typeof IriSP.jQuery === "undefined") |
|
|
346 |
{ |
|
|
347 |
IriSP.jQuery = $; |
|
|
348 |
} |
|
|
349 |
|
|
|
350 |
//On charge les marqueurs. |
|
|
351 |
var sourceManager = new IriSP.Model.Directory(), |
|
|
352 |
globalAnnotations = new IriSP.Model.List(sourceManager), |
|
|
353 |
nbFichiers = _this.urls.length, |
|
|
354 |
fichiersCharges = 0; |
|
|
355 |
|
|
|
356 |
for (var i = 0; i < nbFichiers; i++) |
|
|
357 |
{ |
|
44
|
358 |
// console.log('url : ' + _this.urls[i]); |
|
|
359 |
_this.sources[i] = sourceManager.remoteSource({url: _this.urls[i], serializer: IriSP.serializers.ldt}); |
|
|
360 |
_this.sources[i].onLoad(function() |
|
35
|
361 |
{ |
|
44
|
362 |
var source = this; |
|
|
363 |
// console.log(source); |
|
35
|
364 |
globalAnnotations.addElements(source.getAnnotations()); |
|
44
|
365 |
// console.log(source.url + ' ' + source.getAnnotations().length); |
|
35
|
366 |
fichiersCharges++; |
|
|
367 |
if (fichiersCharges == nbFichiers) |
|
|
368 |
{ |
|
|
369 |
// instructions à exécuter quand tout est chargé |
|
|
370 |
_this.annotations = globalAnnotations; |
|
44
|
371 |
// console.log(_this.annotations.length + ' ' + nbFichiers); |
|
|
372 |
console.log(_this.annotations.length + ' annotations loaded from ' + nbFichiers + ' files.'); |
|
|
373 |
|
|
|
374 |
//Si on gère les interactions à la souris. |
|
|
375 |
if(_this.mouseInteractions) |
|
|
376 |
{ |
|
|
377 |
$('body').mousemove(function(e){_this.refreshMainPointer(e.pageX, e.pageY, _this)}); |
|
|
378 |
} |
|
|
379 |
|
|
|
380 |
// if(false) |
|
|
381 |
// { |
|
|
382 |
if(_this.prephaseEnabled) |
|
|
383 |
{ |
|
|
384 |
_this.init(); |
|
|
385 |
_this.showNImages(0); |
|
|
386 |
_this.currentMode = "NO-USER"; |
|
|
387 |
} |
|
|
388 |
else |
|
|
389 |
{ |
|
|
390 |
_this.showNImages(20); |
|
|
391 |
_this.currentMode = "MOSAIC"; |
|
|
392 |
} |
|
|
393 |
// } |
|
|
394 |
|
|
|
395 |
// /!\ // |
|
|
396 |
// _this.currentMode = "FILTER"; |
|
|
397 |
// _this.showNImages(20); |
|
|
398 |
//_this.isSearchByCurvesOn = true; |
|
|
399 |
// _this.startSearch(); |
|
|
400 |
// console.log('CANVAS READY'); |
|
|
401 |
// /!\ // |
|
|
402 |
|
|
|
403 |
/*_this.currentSearchGesture = 'bend'; |
|
|
404 |
_this.currentMode = 'FILTER'; |
|
|
405 |
_this.searchFilter('bend');*/ |
|
|
406 |
|
|
|
407 |
_this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]); |
|
35
|
408 |
} |
|
|
409 |
}); |
|
|
410 |
} |
|
|
411 |
} |
|
|
412 |
|
|
|
413 |
/* |
|
|
414 |
* Charge les paramètres du Front. Local (true/false) est le mode de chargement des données. |
|
|
415 |
*/ |
|
|
416 |
mosaic.prototype.loadParameters = function(file_path) |
|
|
417 |
{ |
|
|
418 |
var _this = this; |
|
|
419 |
|
|
44
|
420 |
var supposedToBeInt = ['length', 'imagesToShow', 'totalImages', 'timePrezoom', 'timePreUnzoom', 'timeZoom', 'zoomTime', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeANFade', 'timeFilling', 'zoomedMargin', 'timeoutZoom', 'timeoutUnzoom', 'timeoutMoveToNeighbour', 'timeoutPointersIdle', 'timeoutAreBothPointersHere', 'timeoutRemoveNotificationByGesture', 'timeoutRemoveFailedNotificationByGesture', 'timeoutNotifySwipe', 'timeoutSelectTL', 'timeoutSlideTL', 'timeoutCanNotifyHelp', 'timeoutRemoveSpinner', 'timeoutNouser', 'timeoutNextDrawCurve']; |
|
35
|
421 |
var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage']; |
|
|
422 |
|
|
|
423 |
$.getJSON(file_path, function(data) |
|
32
|
424 |
{ |
|
35
|
425 |
for(key in data) |
|
32
|
426 |
{ |
|
35
|
427 |
var val = data[key]; |
|
|
428 |
|
|
|
429 |
if(_.include(supposedToBeInt, key)) |
|
|
430 |
{ |
|
|
431 |
var intVal = parseInt(val); |
|
|
432 |
if(isNaN(intVal)) |
|
|
433 |
{ |
|
44
|
434 |
// console.log(_this.default_config); |
|
35
|
435 |
_this.config[key] = _this.default_config[key]; |
|
|
436 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Int). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
437 |
} |
|
|
438 |
else |
|
|
439 |
{ |
|
|
440 |
_this.config[key] = intVal; |
|
|
441 |
} |
|
|
442 |
} |
|
|
443 |
else if(_.include(supposedToBeFloat, key)) |
|
|
444 |
{ |
|
|
445 |
var floatVal = parseFloat(val); |
|
|
446 |
if(isNaN(floatVal)) |
|
|
447 |
{ |
|
|
448 |
_this.config[key] = _this.default_config[key]; |
|
|
449 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Float). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
450 |
} |
|
|
451 |
else |
|
|
452 |
{ |
|
|
453 |
_this.config[key] = floatVal; |
|
|
454 |
} |
|
|
455 |
} |
|
|
456 |
else |
|
|
457 |
{ |
|
|
458 |
_this.config[key] = val; |
|
|
459 |
} |
|
|
460 |
} |
|
|
461 |
|
|
|
462 |
//On remplit le tableau d'ids. |
|
|
463 |
for(var i = 0 ; i < _this.config['totalImages'] ; i++) |
|
|
464 |
_this.ids.push(i); |
|
|
465 |
//On les mélange. |
|
|
466 |
_this.ids.sort(function() |
|
|
467 |
{ |
|
|
468 |
return 0.5 - Math.random() |
|
|
469 |
}); |
|
|
470 |
|
|
|
471 |
//On remplit le tableau d'ids destiné à afficher les snapshots au fur et à mesure. |
|
|
472 |
for(var i = 0 ; i < _this.config['imagesToShow'] ; i++) |
|
|
473 |
_this.fillingIds.push(i); |
|
|
474 |
//On les mélange. |
|
|
475 |
_this.fillingIds.sort(function() |
|
|
476 |
{ |
|
|
477 |
return 0.5 - Math.random() |
|
|
478 |
}); |
|
|
479 |
|
|
|
480 |
if(_this.config['local'] == 'true') |
|
|
481 |
{ |
|
44
|
482 |
// console.log("Loading local metadata."); |
|
35
|
483 |
_this.loadFromJson('./player/json/local_videos.json'); |
|
|
484 |
} |
|
|
485 |
else |
|
|
486 |
{ |
|
44
|
487 |
// console.log("Loading online metadata."); |
|
35
|
488 |
_this.loadFromJson('./player/json/online_videos.json'); |
|
32
|
489 |
} |
|
44
|
490 |
|
|
|
491 |
//On initialise le client. |
|
|
492 |
_this.client = new client(_this.config['host'], _this.config['port'], _this); |
|
32
|
493 |
}); |
|
30
|
494 |
} |
|
|
495 |
|
|
|
496 |
/* |
|
35
|
497 |
* Phase principale (utilisateur non détecté). Une vidéo se lance aléatoirement. |
|
|
498 |
* L'interface est identique à celle du zoom, mais sans interaction possible avec les voisins, ni les controles timeline. |
|
|
499 |
* Lors de la fin d'une lecture, on dézoome vers la mosaïque, puis on rezoome vers un autre snapshot (aléatoire). |
|
|
500 |
*/ |
|
|
501 |
mosaic.prototype.init = function() |
|
|
502 |
{ |
|
|
503 |
var _this = this; |
|
44
|
504 |
|
|
35
|
505 |
if(this.currentRandomVideoIdx > this.config['imagesToShow']) |
|
|
506 |
{ |
|
|
507 |
this.currentRandomVideoIdx = 0; |
|
|
508 |
} |
|
|
509 |
|
|
44
|
510 |
|
|
35
|
511 |
this.previousZoomedSN = $('#snapshotDiv-' + this.fillingIds[this.currentRandomVideoIdx]); |
|
|
512 |
this.previousId = $('img', this.previousZoomedSN).attr('id'); |
|
|
513 |
|
|
44
|
514 |
// console.log('CURRENT MODE : ' + _this.currentMode); |
|
|
515 |
// console.log('ids', this.fillingIds[this.currentRandomVideoIdx]); |
|
35
|
516 |
|
|
|
517 |
this.previousZoomedSN.fadeTo(this.config['timePrezoom'], 1, function() |
|
|
518 |
{ |
|
44
|
519 |
// console.log('CURRENT MODE : ' + _this.currentMode); |
|
35
|
520 |
_this.zoom(); |
|
|
521 |
_this.currentRandomVideoIdx++; |
|
|
522 |
}); |
|
|
523 |
} |
|
|
524 |
|
|
|
525 |
/* |
|
|
526 |
* Remplissage de la mosaïque en fonction du nombre d'images à afficher. |
|
|
527 |
*/ |
|
|
528 |
mosaic.prototype.showNImages = function(n) |
|
|
529 |
{ |
|
44
|
530 |
if(this.currentlyMoving) |
|
|
531 |
{ |
|
|
532 |
return; |
|
|
533 |
} |
|
|
534 |
|
|
|
535 |
// console.log('INCOMING ----- ' + n); |
|
|
536 |
//Si il y a plus d'un snapshot à afficher, on entre dans le mode INCOMING avec en paramètre le nombre à afficher. |
|
|
537 |
if(n > 1 && n < this.config['imagesToShow']) |
|
35
|
538 |
{ |
|
|
539 |
this.currentMode = "INCOMING-" + n; |
|
|
540 |
this.unzoom(); |
|
44
|
541 |
this.currentSearchGesture = ''; |
|
|
542 |
$('.notifications').remove(); |
|
|
543 |
this.isMosaicFiltered = false; |
|
|
544 |
this.isCurrentlyInASearchByGesture = false; |
|
|
545 |
$('#mainPointer').fadeTo(this.config['timePrezoom'], 0); |
|
|
546 |
$('#secondPointer').fadeTo(this.config['timePrezoom'], 0); |
|
|
547 |
$('#spinner').remove(); |
|
|
548 |
this.deselectAllNeighbours(); |
|
|
549 |
$('.prezoomContainers').remove(); |
|
|
550 |
} |
|
|
551 |
// console.log('n : ' + n); |
|
|
552 |
if(n >= this.config['imagesToShow']) |
|
|
553 |
{ |
|
|
554 |
// this.unzoom(); |
|
|
555 |
if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING-") > -1) |
|
|
556 |
{ |
|
|
557 |
this.currentMode = "INCOMING-20"; |
|
|
558 |
this.unzoom(); |
|
|
559 |
this.currentMode = "MOSAIC"; |
|
|
560 |
$('.notifications').remove(); |
|
|
561 |
this.mosaicSelectionAndSearch(); |
|
|
562 |
clearTimeout(this.nouserTimeout); |
|
|
563 |
console.log('OK'); |
|
|
564 |
} |
|
|
565 |
//On affiche les notifications. |
|
|
566 |
// this.notifySelectionSearchMosaicFull(); |
|
|
567 |
|
|
|
568 |
// $('#mainPointer').fadeTo(this.config['timePrezoom'], 1); |
|
|
569 |
// $('#secondPointer').fadeTo(this.config['timePrezoom'], 1); |
|
35
|
570 |
} |
|
|
571 |
|
|
44
|
572 |
//Pour les snapshots à afficher. |
|
35
|
573 |
for(var i = 0 ; i < n ; i++) |
|
|
574 |
{ |
|
44
|
575 |
//Si les snapshots ne sont pas affichés. |
|
|
576 |
if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') < 1) |
|
35
|
577 |
{ |
|
44
|
578 |
//On les fait apparaître. |
|
|
579 |
$('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config['timeFilling'], '1'); |
|
35
|
580 |
} |
|
|
581 |
} |
|
44
|
582 |
//Pour ceux à masquer. |
|
|
583 |
for(var i = n ; i < this.config['imagesToShow'] ; i++) |
|
35
|
584 |
{ |
|
44
|
585 |
//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). |
|
|
586 |
if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') > 0 && this.fillingIds[i] != this.currentRandomVideoIdx) |
|
35
|
587 |
{ |
|
44
|
588 |
//On les masque. |
|
|
589 |
$('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config['timeFilling'], '0'); |
|
|
590 |
} |
|
|
591 |
} |
|
35
|
592 |
} |
|
|
593 |
|
|
|
594 |
/* |
|
|
595 |
* Gère les événements de contrôle dans la mosaïque. |
|
|
596 |
*/ |
|
|
597 |
mosaic.prototype.manageControlEvents = function(event) |
|
|
598 |
{ |
|
44
|
599 |
// console.log('manage'); |
|
|
600 |
|
|
|
601 |
var _this = this; |
|
|
602 |
|
|
|
603 |
if(typeof event === 'undefined') |
|
|
604 |
{ |
|
|
605 |
return; |
|
|
606 |
} |
|
|
607 |
|
|
|
608 |
var gestureReceived = ''; |
|
|
609 |
|
|
35
|
610 |
//Sinon si on a appuyé sur 'g' ou 'G'. |
|
44
|
611 |
// if(event.which == 103 || event.which == 71) |
|
|
612 |
/*if(event == "CURVES") |
|
35
|
613 |
{ |
|
|
614 |
//Si on est déjà en recherche par courbes. |
|
|
615 |
if(this.currentMode == "SEARCH" || this.currentMode == "FILTER") |
|
|
616 |
{ |
|
|
617 |
//On quitte cette recherche. |
|
|
618 |
this.leaveSearch(); |
|
|
619 |
//Si on était en mode recherche. |
|
|
620 |
if(this.currentMode == "SEARCH") |
|
|
621 |
{ |
|
|
622 |
//On revient dans la vidéo. |
|
|
623 |
this.currentMode = "VIDEO"; |
|
|
624 |
} |
|
|
625 |
else |
|
|
626 |
{ |
|
|
627 |
//Sinon c'est qu'on était dans la mosaïque. |
|
|
628 |
this.currentMode = "MOSAIC"; |
|
|
629 |
} |
|
|
630 |
} |
|
|
631 |
else |
|
|
632 |
{ |
|
|
633 |
//Si on est en plein écran. |
|
|
634 |
if(this.fullscreen) |
|
|
635 |
{ |
|
|
636 |
//On entre en mode recherche. |
|
|
637 |
this.currentMode = "SEARCH"; |
|
|
638 |
} |
|
|
639 |
//Sinon. |
|
|
640 |
else |
|
|
641 |
{ |
|
|
642 |
//On entre en mode filtrage. |
|
|
643 |
this.currentMode = "FILTER"; |
|
|
644 |
} |
|
|
645 |
|
|
|
646 |
this.startSearch(); |
|
|
647 |
} |
|
|
648 |
} |
|
|
649 |
//Si c'est a ou A. |
|
44
|
650 |
// else if(event.which == 65 || event.which == 97) |
|
|
651 |
else if(event == "HELP") |
|
35
|
652 |
{ |
|
|
653 |
if(!this.helpDisplayed) |
|
|
654 |
{ |
|
|
655 |
this.notifyHelp(); |
|
|
656 |
} |
|
|
657 |
else |
|
|
658 |
{ |
|
|
659 |
this.removeHelp(); |
|
|
660 |
} |
|
|
661 |
} |
|
|
662 |
//Si c'est v ou V. |
|
44
|
663 |
// else if(event.which == 86 || event.which == 118) |
|
|
664 |
else if(event == "NOTIFY-SEARCH") |
|
35
|
665 |
{ |
|
|
666 |
this.notifySearchMarkers('run;jump;fall'); |
|
|
667 |
} |
|
|
668 |
//Si c'est b ou B. |
|
44
|
669 |
// else if(event.which == 66 || event.which == 98) |
|
|
670 |
else if(event == "REMOVE-SEARCH") |
|
35
|
671 |
{ |
|
|
672 |
this.removeSearchMarkers(); |
|
|
673 |
} |
|
|
674 |
//Si c'est k ou K. |
|
44
|
675 |
// else if(event.which == 75 || event.which == 107) |
|
|
676 |
else if(event == "FILTER") |
|
35
|
677 |
{ |
|
|
678 |
this.searchFilter('circle'); |
|
|
679 |
} |
|
|
680 |
//Si c'est l ou L. |
|
44
|
681 |
// else if(event.which == 76 || event.which == 108) |
|
|
682 |
else if(event == "REMOVE-FILTER") |
|
35
|
683 |
{ |
|
|
684 |
this.removeFilter(); |
|
|
685 |
} |
|
|
686 |
//Si on a appuié sur la touche 'q' ou 'Q'; |
|
44
|
687 |
// else if(event.which == 113 || event.which == 81) |
|
|
688 |
else if(event == "UNZOOM") |
|
35
|
689 |
{ |
|
|
690 |
this.unzoom(); |
|
44
|
691 |
}*/ |
|
|
692 |
// else if(event.which == 111 || event.which == 79) |
|
|
693 |
if(event.indexOf("INCOMING-") != -1 && this.prephaseEnabled) |
|
35
|
694 |
{ |
|
44
|
695 |
// console.log(this.date() + ' ' + event); |
|
|
696 |
// console.log('CAN START : ' + this.canStart); |
|
|
697 |
if(this.canStart) |
|
35
|
698 |
{ |
|
44
|
699 |
if(this.snapshotsToShow > this.config['imagesToShow']) |
|
|
700 |
{ |
|
|
701 |
this.snapshotsToShow = this.config['imagesToShow']; |
|
|
702 |
} |
|
|
703 |
else |
|
|
704 |
{ |
|
|
705 |
var params = event.split('-'); |
|
|
706 |
// console.log(event); |
|
|
707 |
this.snapshotsToShow = params[1]; |
|
|
708 |
} |
|
|
709 |
|
|
|
710 |
//Si la position de l'utilisateur a changé. |
|
|
711 |
if(event != this.lastIncomingMessage) |
|
|
712 |
{ |
|
|
713 |
console.log(this.snapshotsToShow); |
|
|
714 |
this.lastIncomingMessage = event; |
|
|
715 |
this.showNImages(this.snapshotsToShow); |
|
|
716 |
} |
|
35
|
717 |
} |
|
|
718 |
|
|
44
|
719 |
clearTimeout(this.nouserTimeout); |
|
|
720 |
this.nouserTimeout = setTimeout(function() |
|
|
721 |
{ |
|
|
722 |
/*_this.showNImages(0); |
|
|
723 |
_this.init(); |
|
|
724 |
_this.canStart = false; |
|
|
725 |
_this.currentMode = "NO-USER";*/ |
|
|
726 |
|
|
|
727 |
window.location.reload(); |
|
|
728 |
// mos = new mosaic('./config.json', default_parameters); |
|
|
729 |
|
|
|
730 |
console.log('NOUSER'); |
|
|
731 |
}, this.config['timeoutNouser']); |
|
35
|
732 |
} |
|
44
|
733 |
else if((event == "NO-USER" || event == "INCOMING-0" || event == "INCOMING-1") && this.prephaseEnabled) |
|
31
|
734 |
{ |
|
44
|
735 |
/*this.showNImages(0); |
|
|
736 |
this.init(); |
|
|
737 |
this.canStart = false; |
|
|
738 |
this.currentMode = "NO-USER";*/ |
|
|
739 |
|
|
|
740 |
window.location.reload(); |
|
|
741 |
// mos = new mosaic('./config.json', default_parameters); |
|
|
742 |
|
|
|
743 |
console.log('NOUSER'); |
|
|
744 |
|
|
|
745 |
/*this.currentMode = "NO-USER"; |
|
|
746 |
this.showNImages(0); |
|
|
747 |
this.canStart = false; |
|
|
748 |
this.init();*/ |
|
31
|
749 |
} |
|
44
|
750 |
// /!\/!\ // |
|
|
751 |
else if(event.indexOf("SWIPE") != -1) |
|
31
|
752 |
{ |
|
44
|
753 |
if(this.player && this.player.widgets && this.playerIsReady && !this.isSwipe) |
|
31
|
754 |
{ |
|
44
|
755 |
this.isSwipe = true; |
|
|
756 |
|
|
|
757 |
if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture)) |
|
|
758 |
{ |
|
|
759 |
this.playNextVideo(); |
|
|
760 |
} |
|
|
761 |
|
|
|
762 |
//L'utilisateur a fait un swipe left. |
|
|
763 |
if(event.indexOf("LEFT") != -1) |
|
|
764 |
{ |
|
|
765 |
this.player.widgets[0].switchToMarker(true, this.currentSearchGesture); |
|
|
766 |
if(this.currentMode == 'VIDEO') |
|
|
767 |
{ |
|
|
768 |
$('.notifications').remove(); |
|
|
769 |
this.videoSwipe('left'); |
|
|
770 |
} |
|
|
771 |
else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture) |
|
|
772 |
{ |
|
|
773 |
$('.notifications').remove(); |
|
|
774 |
this.searchSearchAndSwipe('left'); |
|
|
775 |
} |
|
|
776 |
else if(this.currentMode == 'SEARCH' && this.currentSearchGesture) |
|
|
777 |
{ |
|
|
778 |
$('.notifications').remove(); |
|
|
779 |
this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'left'); |
|
|
780 |
} |
|
|
781 |
} |
|
|
782 |
//L'utilisateur a fait un swipe right. |
|
|
783 |
else if(event.indexOf("RIGHT") != -1) |
|
|
784 |
{ |
|
|
785 |
this.player.widgets[0].switchToMarker(false, this.currentSearchGesture); |
|
|
786 |
if(this.currentMode == 'VIDEO') |
|
|
787 |
{ |
|
|
788 |
$('.notifications').remove(); |
|
|
789 |
this.videoSwipe('right'); |
|
|
790 |
} |
|
|
791 |
else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture) |
|
|
792 |
{ |
|
|
793 |
$('.notifications').remove(); |
|
|
794 |
this.searchSearchAndSwipe('right'); |
|
|
795 |
} |
|
|
796 |
else if(this.currentMode == 'SEARCH' && this.currentSearchGesture) |
|
|
797 |
{ |
|
|
798 |
$('.notifications').remove(); |
|
|
799 |
this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'right'); |
|
|
800 |
} |
|
|
801 |
} |
|
|
802 |
|
|
|
803 |
//On le fait disparaitre au bout d'un certain temps. |
|
|
804 |
this.notifySwipeTimeout = setTimeout(function() |
|
|
805 |
{ |
|
|
806 |
_this.isSwipe = false; |
|
|
807 |
|
|
|
808 |
// /!\ // |
|
|
809 |
$('.notifications').remove(); |
|
|
810 |
|
|
|
811 |
if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture) |
|
|
812 |
{ |
|
|
813 |
_this.searchSearch(); |
|
|
814 |
} |
|
|
815 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture) |
|
|
816 |
{ |
|
|
817 |
_this.searchGesture(_this.currentSearchGesture, 'valid'); |
|
|
818 |
} |
|
|
819 |
|
|
|
820 |
}, this.config['timeoutNotifySwipe']); |
|
31
|
821 |
} |
|
|
822 |
} |
|
44
|
823 |
else if(event.indexOf("BEND") != -1 || event.indexOf('KNEE-UP') != -1 || event.indexOf('FALL') != -1 || event.indexOf('JUMP') != -1) |
|
|
824 |
{ |
|
|
825 |
gestureReceived = event.toLowerCase(); |
|
|
826 |
gestureReceived = gestureReceived.replace('wave', 'hello'); |
|
|
827 |
this.currentSearchGesture = gestureReceived; |
|
|
828 |
} |
|
|
829 |
else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere) |
|
|
830 |
{ |
|
|
831 |
if(this.currentMode == 'SEARCH') |
|
31
|
832 |
{ |
|
44
|
833 |
this.notifyHelp(false); |
|
31
|
834 |
} |
|
44
|
835 |
else if(this.currentMode == 'FILTER') |
|
33
|
836 |
{ |
|
44
|
837 |
this.notifyHelp(true); |
|
31
|
838 |
} |
|
|
839 |
} |
|
33
|
840 |
|
|
44
|
841 |
if(gestureReceived != '') |
|
31
|
842 |
{ |
|
44
|
843 |
if(this.currentMode == "SEARCH" && this.playerIsReady) |
|
35
|
844 |
{ |
|
44
|
845 |
this.player.widgets[0].searchByGesture(gestureReceived); |
|
|
846 |
this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture; |
|
|
847 |
|
|
|
848 |
$('.notifications').remove(); |
|
|
849 |
this.searchGesture(gestureReceived, 'valid'); |
|
|
850 |
} |
|
|
851 |
else if(this.currentMode == "FILTER") |
|
35
|
852 |
{ |
|
44
|
853 |
if(this.isMosaicFiltered) |
|
|
854 |
{ |
|
|
855 |
// console.log('FILTER !!!'); |
|
|
856 |
// this.notifySearch1Gesture(gestureReceived, 'valid'); |
|
|
857 |
$('.notifications').remove(); |
|
|
858 |
this.filterGesture(gestureReceived, 'valid'); |
|
|
859 |
this.searchFilter(gestureReceived); |
|
|
860 |
} |
|
35
|
861 |
} |
|
31
|
862 |
|
|
44
|
863 |
if(this.helpDisplayed) |
|
|
864 |
{ |
|
|
865 |
this.removeHelp(); |
|
|
866 |
} |
|
|
867 |
} |
|
|
868 |
// /!\/!\ // |
|
30
|
869 |
} |
|
|
870 |
|
|
|
871 |
/* |
|
31
|
872 |
* Chargement du player basé sur le metadataplayer. |
|
|
873 |
*/ |
|
44
|
874 |
mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft, timeToGo) |
|
31
|
875 |
{ |
|
35
|
876 |
var _this = this; |
|
|
877 |
|
|
31
|
878 |
//On configure les options de lancement. |
|
|
879 |
IriSP.libFiles.defaultDir = "../lib/"; |
|
|
880 |
IriSP.widgetsDir = "./player/metadataplayer/" |
|
|
881 |
|
|
32
|
882 |
var videoToPlay = this.videos[this.centerId]; |
|
|
883 |
var currentMetadata = this.urls[this.centerId]; |
|
|
884 |
|
|
31
|
885 |
var _metadata = { |
|
32
|
886 |
url: currentMetadata, |
|
31
|
887 |
format: 'ldt' |
|
|
888 |
}; |
|
35
|
889 |
|
|
31
|
890 |
var _config = { |
|
|
891 |
gui: { |
|
33
|
892 |
zoomTop: zoomTop - this.marginWidth*2, |
|
|
893 |
zoomLeft: zoomLeft, |
|
31
|
894 |
width: newSnWidth, |
|
|
895 |
height: newSnHeight, |
|
|
896 |
container: 'LdtPlayer', |
|
|
897 |
default_options: { |
|
|
898 |
metadata: _metadata |
|
|
899 |
}, |
|
|
900 |
css:'./player/metadataplayer/LdtPlayer-core.css', |
|
|
901 |
widgets: [ |
|
|
902 |
{ |
|
|
903 |
type: "Timeline" |
|
|
904 |
} |
|
|
905 |
] |
|
|
906 |
}, |
|
|
907 |
player:{ |
|
|
908 |
type: 'html5', // player type |
|
32
|
909 |
video: videoToPlay, |
|
31
|
910 |
live: true, |
|
|
911 |
height: newSnHeight, |
|
|
912 |
width: newSnWidth, |
|
|
913 |
autostart: true |
|
|
914 |
} |
|
|
915 |
}; |
|
|
916 |
|
|
|
917 |
//On positionne le player. |
|
|
918 |
$('.LdtPlayer').css( |
|
|
919 |
{ |
|
|
920 |
//display: 'none', |
|
|
921 |
position: 'absolute', |
|
|
922 |
'background-color': '#000000', |
|
|
923 |
top: newZoomTop, |
|
|
924 |
left: newZoomLeft |
|
|
925 |
}); |
|
|
926 |
|
|
|
927 |
//On démarre le player. |
|
32
|
928 |
this.player = null; |
|
44
|
929 |
|
|
32
|
930 |
this.player = new IriSP.Metadataplayer(_config, _metadata); |
|
35
|
931 |
|
|
44
|
932 |
this.player.onLoad(function() |
|
31
|
933 |
{ |
|
44
|
934 |
if(_this.currentMode == 'NO-USER') |
|
35
|
935 |
{ |
|
44
|
936 |
//On peut s'approcher de la kinect. |
|
|
937 |
_this.canStart = true; |
|
|
938 |
console.log('CAN START !'); |
|
|
939 |
// console.log(_this.player); |
|
|
940 |
// console.log(_this.player.popcorn); |
|
35
|
941 |
} |
|
44
|
942 |
//Lorsque le player est en pause (par exemple lorsque le curseur arrive à la fin de la timeline). |
|
|
943 |
if(_this.player.popcorn) |
|
35
|
944 |
{ |
|
44
|
945 |
_this.player.popcorn.listen('pause', function() |
|
35
|
946 |
{ |
|
44
|
947 |
//Si l'utilisateur a mis en pause. |
|
|
948 |
if(_this.userPaused) |
|
|
949 |
{ |
|
|
950 |
|
|
|
951 |
} |
|
|
952 |
//Si la pause est naturelle (fin de la timeline, dézoom, déplacement vers un voisin). |
|
|
953 |
else |
|
|
954 |
{ |
|
|
955 |
//Si c'est en mode sans utilisateur. |
|
|
956 |
if(_this.currentMode == 'NO-USER') |
|
|
957 |
{ |
|
|
958 |
//On dézoome. |
|
|
959 |
_this.unzoom(); |
|
|
960 |
} |
|
|
961 |
//Sinon. |
|
|
962 |
else |
|
|
963 |
{ |
|
|
964 |
//Si ce n'est pas causé par un déplacement ou un dézoom. |
|
|
965 |
if(!_this.currentlyMoving && !_this.currentlyUnzooming) |
|
|
966 |
{ |
|
|
967 |
//On réinitialise la position du curseur à la prochaine lecture de la vidéo. |
|
|
968 |
console.log('REINIT'); |
|
|
969 |
//On passe a la video suivante. |
|
|
970 |
console.log('AUTOMOVE'); |
|
|
971 |
|
|
|
972 |
//Si on est en mode timeline et qu'on est en pause, c'est probablement que l'user a placé le curseur à la fin. |
|
|
973 |
if(_this.currentMode != 'TIMELINE') |
|
|
974 |
{ |
|
|
975 |
_this.playNextVideo(); |
|
|
976 |
} |
|
|
977 |
//_this.timeToGoAt[parseInt(_this.centerId)] = 0; |
|
|
978 |
console.log('time to go at to 0'); |
|
|
979 |
// return; |
|
|
980 |
} |
|
|
981 |
} |
|
|
982 |
} |
|
35
|
983 |
}); |
|
44
|
984 |
// console.log('mosaic filtered : ' + _this.isMosaicFiltered); |
|
|
985 |
|
|
|
986 |
_this.player.popcorn.on("markersready", function() |
|
|
987 |
{ |
|
|
988 |
_this.playerIsReady = true; |
|
|
989 |
|
|
|
990 |
if(_this.currentMode == 'VIDEO' || _this.currentMode == 'SEARCH' || _this.currentMode == 'TIMELINE') |
|
|
991 |
{ |
|
|
992 |
_this.canSwipe = true; |
|
|
993 |
} |
|
|
994 |
|
|
|
995 |
console.log('TIME TO GO AT : ' + _this.timeToGoAt[_this.centerId], _this.centerId, _this.imgs[_this.centerId]); |
|
|
996 |
|
|
|
997 |
if(_this.isMosaicFiltered) |
|
|
998 |
{ |
|
|
999 |
if(_this.currentSearchGesture == '') |
|
|
1000 |
{ |
|
|
1001 |
_this.removeFilter(); |
|
|
1002 |
} |
|
|
1003 |
else |
|
|
1004 |
{ |
|
|
1005 |
_this.currentMode = 'SEARCH'; |
|
|
1006 |
// console.log(_this.currentSearchGesture); |
|
|
1007 |
_this.player.widgets[0].searchByGesture(_this.currentSearchGesture); |
|
|
1008 |
_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture; |
|
|
1009 |
|
|
|
1010 |
if(_this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture)) |
|
|
1011 |
{ |
|
|
1012 |
_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture); |
|
|
1013 |
} |
|
|
1014 |
else |
|
|
1015 |
{ |
|
|
1016 |
_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]); |
|
|
1017 |
} |
|
|
1018 |
} |
|
|
1019 |
} |
|
|
1020 |
// /!\ // |
|
|
1021 |
else |
|
|
1022 |
{ |
|
|
1023 |
if(_this.player.popcorn) |
|
|
1024 |
{ |
|
|
1025 |
_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]); |
|
|
1026 |
} |
|
|
1027 |
} |
|
|
1028 |
}); |
|
35
|
1029 |
} |
|
44
|
1030 |
}); |
|
30
|
1031 |
} |
|
|
1032 |
|
|
|
1033 |
/* |
|
44
|
1034 |
* Permet de tester l'égalité des éléments de deux objets. |
|
30
|
1035 |
* Pour ce faire on compare les éléments définissant ces objets. |
|
|
1036 |
*/ |
|
|
1037 |
$.fn.equals = function(compareTo) |
|
|
1038 |
{ |
|
|
1039 |
if (!compareTo || !compareTo.length || this.length!=compareTo.length) |
|
|
1040 |
{ |
|
|
1041 |
return false; |
|
|
1042 |
} |
|
|
1043 |
for (var i=0; i<this .length; i++) |
|
|
1044 |
{ |
|
|
1045 |
if (this[i]!==compareTo[i]) |
|
|
1046 |
{ |
|
|
1047 |
return false; |
|
|
1048 |
} |
|
|
1049 |
} |
|
|
1050 |
return true; |
|
32
|
1051 |
} |
|
|
1052 |
|
|
|
1053 |
/* |
|
|
1054 |
* Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
|
|
1055 |
*/ |
|
|
1056 |
mosaic.prototype.loadFromJson = function(path) |
|
|
1057 |
{ |
|
|
1058 |
var _this = this; |
|
33
|
1059 |
var i = 0; |
|
32
|
1060 |
|
|
|
1061 |
$.getJSON(path, function(data) |
|
|
1062 |
{ |
|
|
1063 |
$.each(data, function(key, val) |
|
|
1064 |
{ |
|
|
1065 |
$.each(val, function(key_video, val_video) |
|
|
1066 |
{ |
|
|
1067 |
$.getJSON(val_video.metadata, function(meta) |
|
|
1068 |
{ |
|
35
|
1069 |
if(_this.config['local'] == 'true') |
|
|
1070 |
{ |
|
|
1071 |
_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')); |
|
44
|
1072 |
// console.log(meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4')); |
|
35
|
1073 |
} |
|
|
1074 |
else |
|
|
1075 |
{ |
|
|
1076 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
44
|
1077 |
// console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
35
|
1078 |
} |
|
32
|
1079 |
}); |
|
33
|
1080 |
_this.imgs[_this.ids[i]] = val_video.snapshot; |
|
|
1081 |
_this.urls[_this.ids[i]] = val_video.metadata; |
|
44
|
1082 |
//Au départ, on commence à 0 ms dans les vidéos. |
|
|
1083 |
_this.timeToGoAt[_this.ids[i]] = 0; |
|
|
1084 |
// console.log('ids : ' + _this.ids[i]); |
|
33
|
1085 |
i++; |
|
32
|
1086 |
}); |
|
|
1087 |
}); |
|
44
|
1088 |
// console.log('rdy'); |
|
32
|
1089 |
_this.loadMosaic(); |
|
|
1090 |
}); |
|
|
1091 |
} |
|
|
1092 |
|
|
|
1093 |
/* |
|
|
1094 |
* Affecte une vidéo au tableau des vidéos selon son id |
|
|
1095 |
*/ |
|
|
1096 |
mosaic.prototype.affectVideoById = function(metadata_id, video) |
|
|
1097 |
{ |
|
|
1098 |
for (i = 0 ; i < this.urls.length ; i++) |
|
|
1099 |
{ |
|
|
1100 |
if(this.urls[i] == metadata_id) |
|
|
1101 |
{ |
|
|
1102 |
this.videos[i] = video; |
|
|
1103 |
break; |
|
|
1104 |
} |
|
|
1105 |
} |
|
33
|
1106 |
} |
|
|
1107 |
|
|
|
1108 |
/* |
|
35
|
1109 |
* Rebind keypress pour body. |
|
|
1110 |
*/ |
|
|
1111 |
mosaic.prototype.reaffectKeyPress = function() |
|
|
1112 |
{ |
|
|
1113 |
var _this = this; |
|
|
1114 |
|
|
|
1115 |
$('body').keypress(function (event) |
|
|
1116 |
{ |
|
|
1117 |
_this.manageControlEvents(event); |
|
|
1118 |
}); |
|
44
|
1119 |
} |
|
|
1120 |
|
|
|
1121 |
mosaic.prototype.date = function() |
|
|
1122 |
{ |
|
|
1123 |
var date, h, min, s; |
|
|
1124 |
date = new Date(); |
|
|
1125 |
h = date.getHours(); |
|
|
1126 |
min = date.getMinutes(); |
|
|
1127 |
s = date.getSeconds(); |
|
|
1128 |
if (h < 10) |
|
|
1129 |
h = "0" + h; |
|
|
1130 |
if (min < 10) |
|
|
1131 |
min = "0" + min; |
|
|
1132 |
if (s < 10) |
|
|
1133 |
s = "0" + s; |
|
|
1134 |
return (h + ":" + min + ":" + s); |
|
|
1135 |
}; |