20 /* |
20 /* |
21 * Classe définissant la mosaïque. |
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. |
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. |
23 * Contient également les dimensions en px de la mosaïque. |
24 */ |
24 */ |
25 function mosaic(len, imgToShow, zoomPercentage, prezoomPercentage, zoomedMargin) |
25 function mosaic(len, imgToShow, imgTotal, zoomPercentage, prezoomPercentage, zoomedMargin) |
26 { |
26 { |
27 //S'il s'agit d'un rectangle. |
27 //S'il s'agit d'un rectangle. |
28 if(imgToShow % len == 0) |
28 if(imgToShow % len == 0) |
29 { |
29 { |
30 //Longueur horizontale. |
30 //Longueur horizontale. |
31 this.length = len; |
31 this.length = len; |
32 //Nombre d'images dans la mosaïque. |
32 //Nombre d'images dans la mosaïque. |
33 this.imagesToShow = imgToShow; |
33 this.imagesToShow = imgToShow; |
|
34 this.imagesTotal = imgTotal; |
34 //Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
35 //Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
35 this.videos = []; |
36 this.videos = []; |
36 this.urls = []; |
37 this.urls = []; |
37 this.imgs = []; |
38 this.imgs = []; |
38 this.ids = []; |
39 this.ids = []; |
|
40 //On remplit le tableau d'ids. |
|
41 for(var i = 0 ; i < this.imagesTotal ; i++) |
|
42 this.ids.push(i); |
|
43 //On les mélange. |
|
44 this.ids.sort(function() |
|
45 { |
|
46 return 0.5 - Math.random() |
|
47 }); |
|
48 |
|
49 console.log(this.ids); |
|
50 |
39 //Dimensions de la mosaïque en pixels. |
51 //Dimensions de la mosaïque en pixels. |
40 this.width; |
52 this.width; |
41 this.height; |
53 this.height; |
42 //Dimensions d'un snapshot en pixels. |
54 //Dimensions d'un snapshot en pixels. |
43 this.snapshotWidth; |
55 this.snapshotWidth; |
387 mos.centerId = zoomedImgId; |
426 mos.centerId = zoomedImgId; |
388 mos.listenToNeighbours(); |
427 mos.listenToNeighbours(); |
389 mos.currentMode = 'VIDEO'; |
428 mos.currentMode = 'VIDEO'; |
390 |
429 |
391 console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left); |
430 console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left); |
392 |
431 |
393 mos.loadPlayer((zoomedImg.position().top + newZoomTop + mos.MPTop_margin), (zoomedImg.position().left + newZoomLeft), newSnWidth + 1, newSnHeight + 1); |
432 mos.snTop = (zoomedImg.position().top + newZoomTop + mos.MPTop_margin), mos.snLeft = (zoomedImg.position().left + newZoomLeft); |
|
433 mos.snWidth = newSnWidth + 1, mos.snHeight = newSnHeight + 1; |
|
434 |
|
435 mos.loadPlayer(mos.snTop, mos.snLeft, mos.snWidth, mos.snHeight, newZoomTop, newZoomLeft); |
394 |
436 |
395 /*mos.unload(); |
437 /*mos.unload(); |
396 mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ |
438 mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ |
397 }); |
439 }); |
398 } |
440 } |
399 |
441 |
400 /* |
442 /* |
401 * Chargement du player basé sur le metadataplayer. |
443 * Chargement du player basé sur le metadataplayer. |
402 */ |
444 */ |
403 mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight) |
445 mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft) |
404 { |
446 { |
405 //On configure les options de lancement. |
447 //On configure les options de lancement. |
406 IriSP.libFiles.defaultDir = "../lib/"; |
448 IriSP.libFiles.defaultDir = "../lib/"; |
407 IriSP.widgetsDir = "./player/metadataplayer/" |
449 IriSP.widgetsDir = "./player/metadataplayer/" |
408 |
450 |
409 var videoToPlay = this.videos[this.centerId]; |
451 var videoToPlay = this.videos[this.centerId]; |
410 var currentMetadata = this.urls[this.centerId]; |
452 var currentMetadata = this.urls[this.centerId]; |
411 console.log('VIDEO[' + this.centerId + '] : ' + videoToPlay); |
453 console.log('VIDEO[' + this.centerId + '] : ' + videoToPlay); |
412 console.log('MD[' + this.centerId + '] : ' + currentMetadata); |
454 console.log('MD[' + this.centerId + '] : ' + currentMetadata); |
413 |
455 |
414 console.log(newZoomTop + " " + newZoomLeft); |
|
415 |
|
416 var _metadata = { |
456 var _metadata = { |
417 url: currentMetadata, |
457 url: currentMetadata, |
418 format: 'ldt' |
458 format: 'ldt' |
419 }; |
459 }; |
|
460 console.log(zoomTop + " m" + this.marginWidth); |
420 var _config = { |
461 var _config = { |
421 gui: { |
462 gui: { |
|
463 zoomTop: zoomTop - this.marginWidth*2, |
|
464 zoomLeft: zoomLeft, |
422 width: newSnWidth, |
465 width: newSnWidth, |
423 height: newSnHeight, |
466 height: newSnHeight, |
424 container: 'LdtPlayer', |
467 container: 'LdtPlayer', |
425 default_options: { |
468 default_options: { |
426 metadata: _metadata |
469 metadata: _metadata |
774 * Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
826 * Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
775 */ |
827 */ |
776 mosaic.prototype.loadFromJson = function(path) |
828 mosaic.prototype.loadFromJson = function(path) |
777 { |
829 { |
778 var _this = this; |
830 var _this = this; |
|
831 var i = 0; |
779 |
832 |
780 $.getJSON(path, function(data) |
833 $.getJSON(path, function(data) |
781 { |
834 { |
782 $.each(data, function(key, val) |
835 $.each(data, function(key, val) |
783 { |
836 { |
784 // console.log(val); |
837 // console.log(val); |
785 $.each(val, function(key_video, val_video) |
838 $.each(val, function(key_video, val_video) |
786 { |
839 { |
787 $.getJSON(val_video.metadata, function(meta) |
840 $.getJSON(val_video.metadata, function(meta) |
788 { |
841 { |
789 _this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/')); |
842 _this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
790 //console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/')); |
843 //console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/')); |
791 }); |
844 }); |
792 |
845 |
793 _this.imgs.push(val_video.snapshot); |
846 // _this.imgs.push(val_video.snapshot); |
794 _this.urls.push(val_video.metadata); |
847 // _this.urls.push(val_video.metadata); |
|
848 _this.imgs[_this.ids[i]] = val_video.snapshot; |
|
849 _this.urls[_this.ids[i]] = val_video.metadata; |
|
850 i++; |
795 }); |
851 }); |
796 }); |
852 }); |
797 console.log('rdy'); |
853 console.log('rdy'); |
798 _this.loadMosaic(); |
854 _this.loadMosaic(); |
799 }); |
855 }); |
811 this.videos[i] = video; |
867 this.videos[i] = video; |
812 break; |
868 break; |
813 } |
869 } |
814 } |
870 } |
815 } |
871 } |
|
872 |
|
873 /* |
|
874 * Lance une recherche par courbes. |
|
875 */ |
|
876 mosaic.prototype.startSearch = function() |
|
877 { |
|
878 var top, left, width, height, margin_top, inMosaic; |
|
879 //Si on est dans le cas d'un filtrage de mosaïque. |
|
880 if(this.currentMode == "FILTER") |
|
881 { |
|
882 var mainPanel = $('#mainPanel'); |
|
883 top = mainPanel.position().top; |
|
884 left = mainPanel.position().left; |
|
885 width = mainPanel.width(); |
|
886 height = mainPanel.height(); |
|
887 margin_top = this.MPTop_margin; |
|
888 inMosaic = true; |
|
889 } |
|
890 //Sinon si c'est une recherche dans la vidéo. |
|
891 else if(this.currentMode == "SEARCH") |
|
892 { |
|
893 top = this.snTop; |
|
894 left = this.snLeft; |
|
895 width = this.snWidth; |
|
896 height = this.snHeight; |
|
897 margin_top = '0px'; |
|
898 inMosaic = false; |
|
899 } |
|
900 |
|
901 this.searchCanvas = new searchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic); |
|
902 this.searchCanvas.create(); |
|
903 } |
|
904 |
|
905 /* |
|
906 * Quitte une recherche par courbes. |
|
907 */ |
|
908 mosaic.prototype.leaveSearch = function() |
|
909 { |
|
910 this.searchCanvas.leaveSearch(); |
|
911 } |
|
912 |
|
913 /* =============================================== |
|
914 * * |
|
915 * ZONE DES NOTIFICATIONS * |
|
916 * * |
|
917 =============================================== */ |
|
918 |
|
919 /* |
|
920 * Affiche la notification de sélection/recherche lorsque la mosaique est complète. |
|
921 */ |
|
922 mosaic.prototype.notifySelectionSearchMosaicFull = function() |
|
923 { |
|
924 //On spécifie les notifications en div. |
|
925 var notification_selection = "<div id='notify_selection' class='notifications'></div>"; |
|
926 var notification_search = "<div id='notify_search' class='notifications'></div>"; |
|
927 |
|
928 //On les ajoute à la mosaïque. |
|
929 $('#mainPanel').append(notification_selection + notification_search); |
|
930 |
|
931 //On calcule leurs coordonnées et dimensions. |
|
932 var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
933 var notify_margin = parseInt($('.notifications').css('margin')); |
|
934 var selection_left = $(window).width() / 2 - (notify_width * 2 + notify_margin * 3) / 2; |
|
935 var search_left = selection_left + notify_width + notify_margin; |
|
936 |
|
937 //On les positionne. |
|
938 $('#notify_selection').css( |
|
939 { |
|
940 left: selection_left |
|
941 }); |
|
942 $('#notify_search').css( |
|
943 { |
|
944 left: search_left |
|
945 }); |
|
946 |
|
947 //On les fait apparaître. |
|
948 $('.notifications').css( |
|
949 { |
|
950 opacity: "0.9" |
|
951 }); |
|
952 } |
|
953 |
|
954 /* |
|
955 * Supprime la notification de sélection/recherche lorsque la mosaique est complète. |
|
956 */ |
|
957 mosaic.prototype.removeSelectionSearchMosaicFull = function() |
|
958 { |
|
959 $('#notify_selection, #notify_search').remove(); |
|
960 } |
|
961 |
|
962 /* |
|
963 * Affiche la notification de maintient du pointage lors d'une phase de prézoom. |
|
964 */ |
|
965 mosaic.prototype.notifyPointMosaicPrezoom = function() |
|
966 { |
|
967 if($('#notify_point').length > 0) |
|
968 { |
|
969 return; |
|
970 } |
|
971 |
|
972 //On spécifie les notifications en div. |
|
973 var notification_point = "<div id='notify_point' class='notifications'></div>"; |
|
974 |
|
975 //On les ajoute à la mosaïque. |
|
976 $('#mainPanel').append(notification_point); |
|
977 console.log('Append'); |
|
978 //On calcule leurs coordonnées et dimensions. |
|
979 var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
980 var notify_margin = parseInt($('.notifications').css('margin')); |
|
981 var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
982 |
|
983 //On les positionne. |
|
984 $('#notify_point').css( |
|
985 { |
|
986 left: point_left |
|
987 }); |
|
988 |
|
989 //On les fait apparaître. |
|
990 $('.notifications').css( |
|
991 { |
|
992 opacity: "0.9" |
|
993 }); |
|
994 } |
|
995 |
|
996 /* |
|
997 * Supprime la notification de maintient du pointage. |
|
998 */ |
|
999 mosaic.prototype.removePointMosaicPrezoom = function() |
|
1000 { |
|
1001 $('#notify_point').remove(); |
|
1002 } |
|
1003 |
|
1004 /* |
|
1005 * Affiche l'aide. |
|
1006 */ |
|
1007 mosaic.prototype.notifyHelp = function() |
|
1008 { |
|
1009 if(this.helpDisplayed) |
|
1010 { |
|
1011 return; |
|
1012 } |
|
1013 |
|
1014 this.removeSelectionSearchMosaicFull(); |
|
1015 this.removePointMosaicPrezoom(); |
|
1016 |
|
1017 this.helpDisplayed = true; |
|
1018 |
|
1019 var search_2hands_tab = ['no_motion', 'right_angle', 'contact', 'grand_jete', 'circle', 'screw', 'arc', 'rythme', 'slow', 'up_down', 'wave', 'wheel']; |
|
1020 var search_body_tab = ['bend', 'fall', 'jump', 'hello', 'knee_up']; |
|
1021 var controls_1hand_tab = ['selection']; |
|
1022 |
|
1023 //On spécifie les notifications en div. |
|
1024 var search_title = "<div id='search_title'></div>"; |
|
1025 var search_img = "<div id='search_img' class='notify_imgs'></div>"; |
|
1026 var search_2hands_text = "<div id='search_2hands_text'></div>"; |
|
1027 var search_2hands_imgs = "<div id='search_2hands_imgs' class='notify_imgs_big'>"; |
|
1028 |
|
1029 for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
1030 { |
|
1031 search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small'></div>"; |
|
1032 } |
|
1033 search_2hands_imgs += "</div>"; |
|
1034 |
|
1035 var search_body_text = "<div id='search_body_text'></div>"; |
|
1036 var search_body_imgs = "<div id='search_2hands_imgs' class='notify_imgs'>" |
|
1037 |
|
1038 for(var i = 0 ; i < search_body_tab.length ; i++) |
|
1039 { |
|
1040 search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small'></div>"; |
|
1041 } |
|
1042 search_body_imgs += "</div>"; |
|
1043 |
|
1044 var controls_title = "<div id='controls_title'></div>"; |
|
1045 var controls_img = "<div id='controls_img' class='notify_imgs'></div>"; |
|
1046 var controls_1hand_text = "<div id='controls_1hand_text'></div>"; |
|
1047 var controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>"; |
|
1048 |
|
1049 for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
1050 { |
|
1051 controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small'></div>"; |
|
1052 } |
|
1053 controls_1hand_imgs += "</div>"; |
|
1054 |
|
1055 var help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>"; |
|
1056 var help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>"; |
|
1057 |
|
1058 var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>"; |
|
1059 |
|
1060 //On les ajoute à la mosaïque. |
|
1061 $('body').append(notification_help); |
|
1062 |
|
1063 //On calcule leurs coordonnées et dimensions. |
|
1064 var notify_width = $(window).width(), notify_height = $(window).height(); |
|
1065 var notify_margin = parseInt($('#notify_help').css('margin')); |
|
1066 var notify_ = 10; |
|
1067 |
|
1068 //On les positionne. |
|
1069 $('#notify_help').css( |
|
1070 { |
|
1071 left: "0px", |
|
1072 top: "0px", |
|
1073 width: notify_width - notify_margin * 2, |
|
1074 height: notify_height - notify_margin * 2, |
|
1075 "margin-top": notify_margin_top |
|
1076 }); |
|
1077 |
|
1078 var search_width = $('#help_search').width(); |
|
1079 |
|
1080 $('#search_title').html('Recherche'); |
|
1081 $('#search_2hands_text').html('Gestes à effectuer avec les deux mains'); |
|
1082 $('#search_body_text').html('Gestes à effectuer avec le corps entier'); |
|
1083 |
|
1084 for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
1085 { |
|
1086 $("#2hands_" + search_2hands_tab[i]).css("background-image", "url('./pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
1087 //console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
1088 } |
|
1089 |
|
1090 for(var i = 0 ; i < search_body_tab.length ; i++) |
|
1091 { |
|
1092 $("#body_" + search_body_tab[i]).css("background-image", "url('./pictos/help/" + search_body_tab[i] + ".png')"); |
|
1093 //console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
1094 } |
|
1095 |
|
1096 $('#controls_title').html('Contrôles'); |
|
1097 $('#controls_1hand_text').html('Gestes à effectuer avec une seule main'); |
|
1098 |
|
1099 for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
1100 { |
|
1101 $("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab[i] + ".png')"); |
|
1102 //console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
1103 } |
|
1104 |
|
1105 //On les fait apparaître. |
|
1106 $('#notify_help').css( |
|
1107 { |
|
1108 opacity: "1" |
|
1109 }); |
|
1110 |
|
1111 $('.notify_imgs_big').css( |
|
1112 { |
|
1113 opacity: "1" |
|
1114 }); |
|
1115 } |
|
1116 |
|
1117 /* |
|
1118 * Supprime l'aide. |
|
1119 */ |
|
1120 mosaic.prototype.removeHelp = function() |
|
1121 { |
|
1122 if(!this.helpDisplayed) |
|
1123 { |
|
1124 return; |
|
1125 } |
|
1126 |
|
1127 var _this = this; |
|
1128 |
|
1129 $('#notify_help').fadeOut(this.timeNotifyFade, function() |
|
1130 { |
|
1131 _this.helpDisplayed = false; |
|
1132 $('#notify_help').remove(); |
|
1133 }); |
|
1134 } |