|
32
|
1 |
|
|
|
2 |
IriSP.hc_messages = { |
|
39
|
3 |
Duration_ : "Durée :", |
|
|
4 |
duration_ : "durée :", |
|
32
|
5 |
edit_segment: "Éditer le segment", |
|
|
6 |
segment_down: "Descendre le segment", |
|
|
7 |
segment_up: "Remonter le segment", |
|
39
|
8 |
delete_segment: "Supprimer le segment", |
|
|
9 |
clone_segment: "Cloner le segment", |
|
|
10 |
From_: "De :", |
|
|
11 |
to_: "à :", |
|
|
12 |
segment_title_placeholder: "Segment sans titre", |
|
|
13 |
mashup_title_placeholder: "Hashcut sans titre" |
|
32
|
14 |
} |
|
|
15 |
|
|
27
|
16 |
IriSP.Hashcut = function(options) { |
|
22
|
17 |
|
|
32
|
18 |
|
|
22
|
19 |
/* Load Media List */ |
|
|
20 |
|
|
|
21 |
var directory = new IriSP.Model.Directory(), |
|
|
22 |
project = directory.remoteSource({ |
|
27
|
23 |
url: options.url, |
|
22
|
24 |
serializer: IriSP.serializers.medialist |
|
|
25 |
}), |
|
25
|
26 |
mashup = new IriSP.Model.Mashup(false, project), |
|
27
|
27 |
mediatemplate = _.template('<li class="item-video" data-media-id="<%= id %>"><img src="<%= thumbnail %>" alt="<%= title %>" />' |
|
|
28 |
+ '<span class="video-info"><span class="title-video"><%= title %></span><span class="author"><%= description %></span>' |
|
39
|
29 |
+ '<span class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></span></span></li>'), |
|
27
|
30 |
segmenttemplate = _.template('<li class="item-video" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">' |
|
|
31 |
+ '<img src="<%= annotation.getMedia().thumbnail %>" alt="<%= annotation.getMedia().title %>" />' |
|
39
|
32 |
+ '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>' |
|
27
|
33 |
+ '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>' |
|
32
|
34 |
+ '<ul class="tools"><li><a class="edit" href="#" title="<%= IriSP.hc_messages.edit_segment %>"></a></li><li><a class="bottom" href="#" title="<%= IriSP.hc_messages.segment_down %>"></a></li>' |
|
|
35 |
+ '<li><a class="top" href="#" title="<%= IriSP.hc_messages.segment_up %>"></a></li><li><a class="delete" href="#" title="<%= IriSP.hc_messages.delete_segment %>"></a></li></ul></span></li>'), |
|
|
36 |
viztemplate = _.template('<div class="frise-segment" data-segment-id="<%= segmentid %>" style="background-color:<%= color %>; left:<%= left %>%; width:<%= width %>%;"></div>'), |
|
29
|
37 |
intervaltemplate = _.template('<span class="frise-indication" style="left:<%= left %>%;"><%= time.toString() %></span>'), |
|
|
38 |
mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">' |
|
|
39 |
+ '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= annotation.getMedia().color %>"></div>' |
|
|
40 |
+ '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>' |
|
|
41 |
+ '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">' |
|
39
|
42 |
+ '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>' |
|
|
43 |
+ '<p><%= IriSP.hc_messages.From_ %> <span><%= annotation.begin.toString() %></span> <%= IriSP.hc_messages.to_ %> <span><%= annotation.end.toString() %></span> (<%= IriSP.hc_messages.duration_ %> <span><%= annotation.getDuration().toString() %></span>)</p>' |
|
29
|
44 |
+ '</div></div></div></div>'); |
|
39
|
45 |
|
|
|
46 |
/* Validation of segments and mashup */ |
|
|
47 |
|
|
|
48 |
var segmentcritical = [ |
|
|
49 |
{ |
|
|
50 |
validate: function(_s) { |
|
|
51 |
var _d = _s.getDuration(); |
|
|
52 |
return (_d > 1000 && _d < 180000); |
|
|
53 |
}, |
|
|
54 |
message: "La durée du segment doit être comprise entre 1 seconde et trois minutes" |
|
|
55 |
}, |
|
|
56 |
{ |
|
|
57 |
validate: function(_s) { |
|
|
58 |
return (!!_s.title && _s.title !== IriSP.hc_messages.segment_title_placeholder); |
|
|
59 |
}, |
|
|
60 |
message: "Un titre doit être donné au segment" |
|
|
61 |
} |
|
|
62 |
]; |
|
|
63 |
var segmentwarning = [ |
|
|
64 |
{ |
|
|
65 |
validate: function(_s) { |
|
|
66 |
return (_s.description); |
|
|
67 |
}, |
|
|
68 |
message: "Il est recommandé de donner une description au segment" |
|
|
69 |
} |
|
|
70 |
]; |
|
|
71 |
|
|
|
72 |
var mashupcritical = [ |
|
|
73 |
{ |
|
|
74 |
validate: function(_m) { |
|
|
75 |
return _m.segments.length > 2; |
|
|
76 |
}, |
|
|
77 |
message: "Un hashcut doit être composé d'au moins trois segments" |
|
|
78 |
}, |
|
|
79 |
{ |
|
|
80 |
validate: function(_m) { |
|
|
81 |
return (!!_m.title && _m.title !== IriSP.hc_messages.mashup_title_placeholder); |
|
|
82 |
}, |
|
|
83 |
message: "Un titre doit être donné au hashcut" |
|
|
84 |
} |
|
|
85 |
]; |
|
|
86 |
var mashupwarning = [ |
|
|
87 |
{ |
|
|
88 |
validate: function(_m) { |
|
|
89 |
return !!_m.description |
|
|
90 |
}, |
|
|
91 |
message: "Il est recommandé de donner une description au hashcut" |
|
|
92 |
} |
|
|
93 |
]; |
|
22
|
94 |
|
|
|
95 |
/* Fill left column with Media List */ |
|
25
|
96 |
|
|
22
|
97 |
project.onLoad(function() { |
|
|
98 |
var html = ''; |
|
|
99 |
project.getMedias().forEach(function(_m) { |
|
27
|
100 |
html += mediatemplate(_m); |
|
13
|
101 |
}); |
|
22
|
102 |
$(".col-left .list-video").html(html); |
|
|
103 |
}); |
|
|
104 |
|
|
|
105 |
/* Search Media with left column form */ |
|
|
106 |
|
|
|
107 |
$(".col-left input").on("keyup change input paste", function() { |
|
|
108 |
var val = $(this).val(); |
|
|
109 |
if (val) { |
|
|
110 |
var find = IriSP.Model.regexpFromTextOrArray(val, true), |
|
|
111 |
replace = IriSP.Model.regexpFromTextOrArray(val, false); |
|
|
112 |
} |
|
|
113 |
$(".col-left .item-video").each(function() { |
|
|
114 |
var li = $(this), |
|
|
115 |
title = $(this).find(".title-video"), |
|
|
116 |
titletext = title.text(); |
|
|
117 |
if (val && find.test(titletext)) { |
|
|
118 |
title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>')); |
|
|
119 |
li.show(); |
|
|
120 |
} else { |
|
|
121 |
title.text(titletext); |
|
|
122 |
if (val) { |
|
|
123 |
li.hide(); |
|
13
|
124 |
} else { |
|
22
|
125 |
li.show(); |
|
13
|
126 |
} |
|
22
|
127 |
} |
|
|
128 |
}) |
|
|
129 |
}); |
|
|
130 |
|
|
25
|
131 |
/* Fill right column when mashup is updated */ |
|
|
132 |
|
|
27
|
133 |
function setPointerToCurrentAnnotation() { |
|
|
134 |
if (mashupCurrentAnnotation) { |
|
|
135 |
var p = (mashupCurrentAnnotation.begin + mashupCurrentAnnotation.end) / (2 * mashup.duration); |
|
|
136 |
$(".mashup-description .pointer").css("left", (100 * p) + "%"); |
|
|
137 |
} |
|
25
|
138 |
} |
|
|
139 |
|
|
27
|
140 |
function updateMashupUI() { |
|
|
141 |
var listhtml = '', vizhtml = '', t = 0, k = mashup.duration ? (100 / mashup.duration) : 0; |
|
39
|
142 |
var critical = false, warning = false, messages = []; |
|
27
|
143 |
mashup.segments.forEach(function(_s) { |
|
|
144 |
listhtml += segmenttemplate(_s); |
|
|
145 |
var vizdata = { |
|
|
146 |
left: k * t, |
|
|
147 |
width: k * _s.duration, |
|
32
|
148 |
color: _s.getMedia().color, |
|
|
149 |
segmentid: _s.annotation.id |
|
27
|
150 |
} |
|
|
151 |
vizhtml += viztemplate(vizdata); |
|
39
|
152 |
if (_s.annotation.status === "critical") { |
|
|
153 |
critical = true; |
|
|
154 |
} |
|
27
|
155 |
t += _s.duration.milliseconds; |
|
|
156 |
}); |
|
39
|
157 |
if (critical) { |
|
|
158 |
messages.push("Certains segments ne sont pas valides"); |
|
|
159 |
} |
|
|
160 |
|
|
|
161 |
_(mashupcritical).each(function(sc) { |
|
|
162 |
if (!sc.validate(mashup)) { |
|
|
163 |
critical = true; |
|
|
164 |
messages.push(sc.message); |
|
|
165 |
} |
|
|
166 |
}); |
|
|
167 |
_(mashupwarning).each(function(sc) { |
|
|
168 |
if (!sc.validate(mashup)) { |
|
|
169 |
warning = true; |
|
|
170 |
messages.push(sc.message); |
|
|
171 |
} |
|
|
172 |
}); |
|
|
173 |
mashup.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
|
174 |
if (!messages.length) { |
|
|
175 |
messages.push("Le hashcut est valide !"); |
|
|
176 |
} |
|
|
177 |
$(".publier-button").toggleClass("disable", critical); |
|
|
178 |
|
|
|
179 |
$(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status); |
|
|
180 |
$(".liste-segment .validate-tooltip").html("<ul><li>" + messages.join("</li><li>")+"</li></ul>"); |
|
27
|
181 |
|
|
|
182 |
var intervals = [ 1000, 2000, 5000, 10000, 30000, 60000, 120000, 300000, 600000, 900000, 1800000, 3600000, 7200000 ]; |
|
|
183 |
|
|
|
184 |
function createIntervals(maxn) { |
|
|
185 |
for (var i = 0; i < intervals.length; i++) { |
|
|
186 |
if (mashup.duration / intervals[i] <= maxn) { |
|
|
187 |
var html = ''; |
|
|
188 |
for (var j = intervals[i]; j < mashup.duration; j += intervals[i]) { |
|
|
189 |
html += intervaltemplate({ left: k * j, time: new IriSP.Model.Time(j) }); |
|
|
190 |
} |
|
|
191 |
return html; |
|
|
192 |
} |
|
|
193 |
} |
|
|
194 |
return ""; |
|
|
195 |
} |
|
|
196 |
|
|
|
197 |
$(".col-right .list-video").html(listhtml).find(".item-video:last-child .bottom, .item-video:first-child .top").addClass("disable"); |
|
|
198 |
$(".mashup-total-duration").text(mashup.duration.toString()); |
|
|
199 |
$(".frise-segments").html(vizhtml); |
|
|
200 |
$(".col-right .frise-indications").html(createIntervals(4)); |
|
|
201 |
$(".bloc-pvw .frise-indications").html(createIntervals(8)); |
|
|
202 |
highlightCurrentSegment(); |
|
|
203 |
if (currentMedia === mashup) { |
|
|
204 |
$(".Ldt-Ctrl-Time-Total").text(currentMedia.duration.toString()); |
|
|
205 |
if (mashupTimecode > mashup.duration) { |
|
|
206 |
mashup.setCurrentTime(mashup.duration); |
|
|
207 |
} |
|
|
208 |
changeCurrentAnnotation(); |
|
|
209 |
setPointerToCurrentAnnotation(); |
|
|
210 |
} |
|
|
211 |
} |
|
|
212 |
|
|
|
213 |
mashup.on("change",updateMashupUI); |
|
25
|
214 |
|
|
22
|
215 |
/* Slider */ |
|
|
216 |
|
|
23
|
217 |
var timeSlider = $(".Ldt-Slider"), |
|
29
|
218 |
timeSliderContainer = $(".Ldt-Slider-Container"), |
|
23
|
219 |
slidersRange = 920; |
|
22
|
220 |
timeSlider.slider({ |
|
|
221 |
range: "min", |
|
|
222 |
value: 0, |
|
|
223 |
min: 0, |
|
23
|
224 |
max: slidersRange, |
|
22
|
225 |
slide: function(event, ui) { |
|
23
|
226 |
if (currentMedia) { |
|
|
227 |
var t = currentMedia.duration * ui.value / slidersRange; |
|
|
228 |
currentMedia.setCurrentTime(t); |
|
|
229 |
} |
|
22
|
230 |
} |
|
|
231 |
}); |
|
|
232 |
|
|
|
233 |
var timeSliderHandle = timeSlider.find('.ui-slider-handle'), |
|
|
234 |
timeSliderMaximized = false, |
|
|
235 |
timeSliderTimeoutId = false, |
|
|
236 |
timeSliderMinimizedHeight = 4, |
|
|
237 |
timeSliderMaximizedHeight = 10, |
|
|
238 |
timeSliderTimeoutDuration = 1500, |
|
|
239 |
timeTooltip = $(".Ldt-Slider-Time"); |
|
|
240 |
|
|
29
|
241 |
timeSliderContainer.css(calculateSliderCss(timeSliderMinimizedHeight)); |
|
22
|
242 |
timeSliderHandle.css(calculateHandleCss(timeSliderMinimizedHeight)); |
|
|
243 |
|
|
|
244 |
function timeSliderMouseOver() { |
|
|
245 |
if (timeSliderTimeoutId) { |
|
|
246 |
window.clearTimeout(timeSliderTimeoutId); |
|
|
247 |
timeSliderTimeoutId = false; |
|
|
248 |
} |
|
|
249 |
if (!timeSliderMaximized) { |
|
|
250 |
timeSliderAnimateToHeight(timeSliderMaximizedHeight); |
|
|
251 |
timeSliderMaximized = true; |
|
|
252 |
} |
|
|
253 |
} |
|
|
254 |
|
|
|
255 |
function timeSliderMouseOut() { |
|
|
256 |
timeTooltip.hide(); |
|
|
257 |
if (timeSliderTimeoutId) { |
|
|
258 |
clearTimeout(timeSliderTimeoutId); |
|
|
259 |
timeSliderTimeoutId = false; |
|
|
260 |
} |
|
|
261 |
timeSliderTimeoutId = setTimeout(function() { |
|
|
262 |
if (timeSliderMaximized) { |
|
|
263 |
timeSliderAnimateToHeight(timeSliderMinimizedHeight); |
|
|
264 |
timeSliderMaximized = false; |
|
|
265 |
} |
|
|
266 |
timeSliderTimeoutId = false; |
|
|
267 |
}, timeSliderTimeoutDuration); |
|
|
268 |
} |
|
|
269 |
|
|
29
|
270 |
timeSliderContainer |
|
22
|
271 |
.mouseover(function() { |
|
|
272 |
timeTooltip.show(); |
|
|
273 |
timeSliderMouseOver(); |
|
|
274 |
}) |
|
29
|
275 |
.mouseout(timeSliderMouseOut); |
|
|
276 |
timeSlider.mousemove(function(_e) { |
|
22
|
277 |
var _x = _e.pageX - timeSlider.offset().left, |
|
23
|
278 |
_t = new IriSP.Model.Time( |
|
|
279 |
); |
|
22
|
280 |
timeTooltip.text(_t.toString()).css("left",_x); |
|
15
|
281 |
}); |
|
22
|
282 |
|
|
|
283 |
$(".Ldt-Ctrl").mouseover(timeSliderMouseOver).mouseout(timeSliderMouseOut); |
|
|
284 |
|
|
|
285 |
function timeSliderAnimateToHeight(_height) { |
|
29
|
286 |
timeSliderContainer.stop().animate( |
|
22
|
287 |
calculateSliderCss(_height), |
|
|
288 |
500, |
|
|
289 |
function() { |
|
|
290 |
IriSP.jQuery(this).css("overflow","visible"); |
|
|
291 |
}); |
|
|
292 |
timeSliderHandle.stop().animate( |
|
|
293 |
calculateHandleCss(_height), |
|
|
294 |
500, |
|
|
295 |
function() { |
|
|
296 |
IriSP.jQuery(this).css("overflow","visible"); |
|
|
297 |
}); |
|
|
298 |
} |
|
|
299 |
|
|
|
300 |
function calculateSliderCss(_size) { |
|
|
301 |
return { |
|
|
302 |
height: _size + "px", |
|
|
303 |
"margin-top": (timeSliderMinimizedHeight - _size) + "px" |
|
|
304 |
}; |
|
|
305 |
} |
|
|
306 |
|
|
|
307 |
function calculateHandleCss(_size) { |
|
|
308 |
return { |
|
|
309 |
height: (2 + _size) + "px", |
|
|
310 |
width: (2 + _size) + "px", |
|
|
311 |
"margin-left": -Math.ceil(2 + _size / 2) + "px" |
|
18
|
312 |
} |
|
22
|
313 |
} |
|
|
314 |
|
|
|
315 |
/* Controller Widget */ |
|
|
316 |
|
|
|
317 |
var volBlock = $(".Ldt-Ctrl-Volume-Control"); |
|
25
|
318 |
|
|
22
|
319 |
$('.Ldt-Ctrl-Sound') |
|
25
|
320 |
.click(function() { |
|
|
321 |
if (currentMedia) { |
|
|
322 |
currentMedia.setMuted(!currentMedia.getMuted()); |
|
|
323 |
} |
|
|
324 |
}) |
|
22
|
325 |
.mouseover(function() { |
|
|
326 |
volBlock.show(); |
|
|
327 |
}) |
|
|
328 |
.mouseout(function() { |
|
|
329 |
volBlock.hide(); |
|
18
|
330 |
}); |
|
22
|
331 |
volBlock.mouseover(function() { |
|
|
332 |
volBlock.show(); |
|
|
333 |
}).mouseout(function() { |
|
|
334 |
volBlock.hide(); |
|
|
335 |
}); |
|
|
336 |
|
|
|
337 |
var volBar = $(".Ldt-Ctrl-Volume-Bar"); |
|
25
|
338 |
|
|
|
339 |
function ctrlVolumeUpdater() { |
|
|
340 |
if (currentMedia) { |
|
|
341 |
var _muted = currentMedia.getMuted(), |
|
|
342 |
_vol = currentMedia.getVolume(); |
|
|
343 |
if (_vol === false) { |
|
|
344 |
_vol = .5; |
|
|
345 |
} |
|
|
346 |
var _soundCtl = $(".Ldt-Ctrl-Sound"); |
|
|
347 |
_soundCtl.removeClass("Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full"); |
|
|
348 |
if (_muted) { |
|
|
349 |
_soundCtl.attr("title", "Activer le son") |
|
|
350 |
.addClass("Ldt-Ctrl-Sound-Mute"); |
|
|
351 |
} else { |
|
|
352 |
_soundCtl.attr("title", "Couper le son") |
|
|
353 |
.addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" ) |
|
|
354 |
} |
|
|
355 |
volBar.slider("value", _muted ? 0 : 100 * _vol); |
|
|
356 |
volBar.attr("title",'Volume : ' + Math.floor(100 * _vol) + '%'); |
|
|
357 |
} |
|
|
358 |
} |
|
|
359 |
|
|
22
|
360 |
volBar.slider({ |
|
|
361 |
slide: function(event, ui) { |
|
25
|
362 |
if (currentMedia) { |
|
|
363 |
currentMedia.setVolume(ui.value / 100); |
|
|
364 |
} |
|
22
|
365 |
} |
|
|
366 |
}); |
|
|
367 |
|
|
23
|
368 |
$(".Ldt-Ctrl-Play").click(function() { |
|
|
369 |
if (currentMedia) { |
|
|
370 |
if (currentMedia.getPaused()) { |
|
|
371 |
currentMedia.play(); |
|
|
372 |
} else { |
|
|
373 |
currentMedia.pause(); |
|
|
374 |
} |
|
|
375 |
} |
|
|
376 |
}); |
|
|
377 |
|
|
25
|
378 |
$(".Ldt-Ctrl-SetIn").click(function() { |
|
27
|
379 |
if (currentMedia && currentSegment) { |
|
|
380 |
currentSegment.setBegin(currentMedia.getCurrentTime()); |
|
25
|
381 |
} |
|
|
382 |
}); |
|
|
383 |
$(".Ldt-Ctrl-SetOut").click(function() { |
|
27
|
384 |
if (currentMedia && currentSegment) { |
|
|
385 |
currentSegment.setEnd(currentMedia.getCurrentTime()); |
|
25
|
386 |
} |
|
|
387 |
}); |
|
|
388 |
|
|
23
|
389 |
/* Slice Widget */ |
|
25
|
390 |
|
|
23
|
391 |
var sliceSlider = $(".Ldt-Slice"), |
|
|
392 |
sliceStartTime; |
|
|
393 |
|
|
|
394 |
sliceSlider.slider({ |
|
|
395 |
range: true, |
|
|
396 |
values: [0, slidersRange], |
|
|
397 |
min: 0, |
|
|
398 |
max: slidersRange, |
|
|
399 |
start: function() { |
|
|
400 |
if (currentMedia) { |
|
|
401 |
if (!currentMedia.getPaused()) { |
|
|
402 |
currentMedia.pause(); |
|
|
403 |
} |
|
|
404 |
} |
|
|
405 |
}, |
|
|
406 |
slide: function(event, ui) { |
|
27
|
407 |
if (currentMedia && currentSegment) { |
|
23
|
408 |
var t = currentMedia.duration * ui.value / slidersRange; |
|
25
|
409 |
if (ui.value === ui.values[0]) { |
|
27
|
410 |
currentSegment.setBegin(t); |
|
25
|
411 |
} else { |
|
27
|
412 |
currentSegment.setEnd(t); |
|
25
|
413 |
} |
|
23
|
414 |
} |
|
|
415 |
} |
|
|
416 |
}); |
|
|
417 |
|
|
25
|
418 |
sliceSlider.find(".ui-slider-handle:first") |
|
|
419 |
.addClass("Ldt-Slice-left-handle") |
|
|
420 |
.click(function() { |
|
27
|
421 |
if (currentMedia && currentSegment) { |
|
|
422 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
25
|
423 |
} |
|
|
424 |
}); |
|
|
425 |
sliceSlider.find(".ui-slider-handle:last") |
|
|
426 |
.addClass("Ldt-Slice-right-handle") |
|
|
427 |
.click(function() { |
|
27
|
428 |
if (currentMedia && currentSegment) { |
|
|
429 |
currentMedia.setCurrentTime(currentSegment.end); |
|
25
|
430 |
} |
|
|
431 |
}); |
|
23
|
432 |
|
|
|
433 |
/* UI Events */ |
|
|
434 |
|
|
|
435 |
function onCurrentMediaPlay() { |
|
|
436 |
$(".Ldt-Ctrl-Play") |
|
|
437 |
.attr("title", "Pause") |
|
|
438 |
.removeClass("Ldt-Ctrl-Play-PlayState") |
|
|
439 |
.addClass("Ldt-Ctrl-Play-PauseState") |
|
|
440 |
} |
|
|
441 |
|
|
|
442 |
function onCurrentMediaPause() { |
|
|
443 |
$(".Ldt-Ctrl-Play") |
|
|
444 |
.attr("title", "Lecture") |
|
|
445 |
.removeClass("Ldt-Ctrl-Play-PauseState") |
|
|
446 |
.addClass("Ldt-Ctrl-Play-PlayState") |
|
|
447 |
} |
|
|
448 |
|
|
|
449 |
function onCurrentMediaTimeupdate(_time) { |
|
|
450 |
$(".Ldt-Ctrl-Time-Elapsed").text(_time.toString()); |
|
|
451 |
timeSlider.slider("value",slidersRange * _time / currentMedia.duration); |
|
|
452 |
} |
|
|
453 |
|
|
27
|
454 |
/* Mashup Player */ |
|
|
455 |
|
|
|
456 |
var mashupCurrentMedia = null, |
|
|
457 |
mashupCurrentAnnotation = null, |
|
|
458 |
mashupSegmentBegin, |
|
|
459 |
mashupSegmentEnd, |
|
|
460 |
mashupTimecode = 0, |
|
|
461 |
mashupSeeking = false, |
|
32
|
462 |
seekdiv = $(".video-wait"), |
|
27
|
463 |
mashupTimedelta; |
|
32
|
464 |
|
|
|
465 |
function showSeek() { |
|
|
466 |
if (mashupSeeking) { |
|
|
467 |
seekdiv.show(); |
|
|
468 |
} |
|
|
469 |
} |
|
|
470 |
|
|
27
|
471 |
function changeCurrentAnnotation() { |
|
|
472 |
if (mashupTimecode >= mashup.duration) { |
|
|
473 |
if (!mashup.paused) { |
|
|
474 |
mashup.paused = true; |
|
|
475 |
mashup.trigger("pause"); |
|
|
476 |
} |
|
|
477 |
mashupTimecode = 0; |
|
|
478 |
} |
|
|
479 |
var _annotation = mashup.getAnnotationAtTime( mashupTimecode ); |
|
|
480 |
if (typeof _annotation === "undefined") { |
|
|
481 |
if (mashupCurrentMedia) { |
|
|
482 |
mashupCurrentMedia.pause(); |
|
|
483 |
if (!mashup.paused) { |
|
|
484 |
mashup.paused = true; |
|
|
485 |
mashup.trigger("pause"); |
|
|
486 |
} |
|
|
487 |
} |
|
|
488 |
return; |
|
|
489 |
} |
|
|
490 |
mashupCurrentAnnotation = _annotation; |
|
|
491 |
mashupSegmentBegin = mashupCurrentAnnotation.annotation.begin.milliseconds; |
|
|
492 |
mashupSegmentEnd = mashupCurrentAnnotation.annotation.end.milliseconds; |
|
|
493 |
mashupTimedelta = mashupSegmentBegin - mashupCurrentAnnotation.begin.milliseconds; |
|
|
494 |
mashupCurrentMedia = mashupCurrentAnnotation.getMedia(); |
|
|
495 |
|
|
|
496 |
project.getMedias().forEach(function(_media) { |
|
|
497 |
if (_media !== mashupCurrentMedia) { |
|
|
498 |
_media.hide(); |
|
|
499 |
_media.pause(); |
|
|
500 |
} else { |
|
|
501 |
_media.show(); |
|
|
502 |
} |
|
|
503 |
}); |
|
|
504 |
|
|
|
505 |
mashupCurrentMedia.setCurrentTime( mashupTimecode + mashupTimedelta); |
|
|
506 |
mashupCurrentMedia.seeking = true; |
|
|
507 |
|
|
|
508 |
if (!mashup.paused) { |
|
|
509 |
mashupCurrentMedia.play(); |
|
|
510 |
mashupSeeking = true; |
|
32
|
511 |
setTimeout(showSeek,200); |
|
27
|
512 |
} |
|
|
513 |
mashup.trigger("timeupdate", new IriSP.Model.Time(mashupTimecode)); |
|
|
514 |
|
|
|
515 |
} |
|
|
516 |
|
|
22
|
517 |
/* Set current Media */ |
|
25
|
518 |
|
|
27
|
519 |
var currentMedia, currentSegment; |
|
22
|
520 |
|
|
39
|
521 |
function updateSegmentUI() { |
|
27
|
522 |
if (currentMedia && currentSegment) { |
|
|
523 |
var start = currentSegment.begin, |
|
|
524 |
end = currentSegment.end, |
|
|
525 |
dur = currentSegment.getDuration(), |
|
|
526 |
f = slidersRange / currentMedia.duration, |
|
|
527 |
tangleStart = $(".tangle-start"), |
|
|
528 |
tangleEnd = $(".tangle-end"), |
|
29
|
529 |
tangleDuration = $(".tangle-duration"), |
|
|
530 |
k = 100 / currentMedia.duration, |
|
|
531 |
p = k * (start + end) / 2; |
|
25
|
532 |
sliceSlider.slider( "values", [ f * start, f * end ] ); |
|
27
|
533 |
tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); |
|
|
534 |
tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); |
|
|
535 |
tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); |
|
39
|
536 |
$(".segmentation .pointer").css("left", p + "%"); |
|
29
|
537 |
$(".media-current-section").css({ |
|
|
538 |
left: (k * start) + "%", |
|
|
539 |
width: (k * dur) + "%" |
|
39
|
540 |
}); |
|
|
541 |
var messages = [], |
|
|
542 |
critical = false, |
|
|
543 |
warning = false; |
|
|
544 |
_(segmentcritical).each(function(sc) { |
|
|
545 |
if (!sc.validate(currentSegment)) { |
|
|
546 |
critical = true; |
|
|
547 |
messages.push(sc.message); |
|
|
548 |
} |
|
|
549 |
}); |
|
|
550 |
_(segmentwarning).each(function(sc) { |
|
|
551 |
if (!sc.validate(currentSegment)) { |
|
|
552 |
warning = true; |
|
|
553 |
messages.push(sc.message); |
|
|
554 |
} |
|
|
555 |
}); |
|
|
556 |
currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); |
|
|
557 |
if (!messages.length) { |
|
|
558 |
messages.push("Le segment est valide !") |
|
|
559 |
} |
|
|
560 |
currentSegment.status_messages = messages; |
|
|
561 |
|
|
|
562 |
$(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); |
|
|
563 |
$(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>"); |
|
25
|
564 |
} |
|
|
565 |
} |
|
|
566 |
|
|
27
|
567 |
var addMode; |
|
|
568 |
|
|
|
569 |
function setMedia(media) { |
|
23
|
570 |
if (currentMedia) { |
|
|
571 |
currentMedia.pause(); |
|
|
572 |
} |
|
27
|
573 |
currentMedia = media; |
|
22
|
574 |
if (currentMedia.elementType == "media") { |
|
27
|
575 |
$("video").hide(); |
|
23
|
576 |
showSegmentation(); |
|
32
|
577 |
if (!currentMedia.loaded) { |
|
|
578 |
seekdiv.show(); |
|
|
579 |
} |
|
27
|
580 |
var currentvideo = $('#video_' + currentMedia.id); |
|
23
|
581 |
if (!currentvideo.length) { |
|
|
582 |
addMediaPlayer(currentMedia); |
|
|
583 |
} |
|
|
584 |
$(".tab-media-title").text(currentMedia.title); |
|
27
|
585 |
|
|
|
586 |
addMode = !(currentSegment && mashup.hasAnnotation(currentSegment)); |
|
|
587 |
|
|
|
588 |
if (!currentSegment) { |
|
|
589 |
currentSegment = new IriSP.Model.Annotation(false, project); |
|
|
590 |
currentSegment.setMedia(currentMedia.id); |
|
|
591 |
currentSegment.setBegin(0); |
|
|
592 |
currentSegment.setEnd(currentMedia.duration); |
|
39
|
593 |
currentSegment.title = IriSP.hc_messages.segment_title_placeholder; |
|
|
594 |
currentSegment.description = ""; |
|
27
|
595 |
currentSegment.on("change-begin", function() { |
|
|
596 |
if (currentMedia && currentSegment === this) { |
|
25
|
597 |
currentMedia.setCurrentTime(this.begin); |
|
39
|
598 |
updateSegmentUI(); |
|
25
|
599 |
} |
|
|
600 |
}); |
|
27
|
601 |
currentSegment.on("change-end", function() { |
|
|
602 |
if (currentMedia && currentSegment === this) { |
|
25
|
603 |
currentMedia.setCurrentTime(this.end); |
|
39
|
604 |
updateSegmentUI(); |
|
25
|
605 |
} |
|
|
606 |
}); |
|
27
|
607 |
currentSegment.on("enter", function() { |
|
|
608 |
if (currentMedia === mashup) { |
|
|
609 |
$(".annotation-title").text(this.title); |
|
|
610 |
$(".annotation-begin").text(this.begin.toString()); |
|
|
611 |
$(".annotation-end").text(this.end.toString()); |
|
|
612 |
$(".annotation-media-title").text(this.getMedia().title); |
|
|
613 |
$(".annotation-description").text(this.description); |
|
|
614 |
setPointerToCurrentAnnotation(); |
|
32
|
615 |
highlightCurrentSegment(); |
|
27
|
616 |
} |
|
29
|
617 |
}); |
|
25
|
618 |
} |
|
27
|
619 |
if (currentMedia.loaded) { |
|
|
620 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
|
621 |
} |
|
|
622 |
$(".add-segment").val(addMode ? "Ajouter au Hashcut" : "Sauvegarder"); |
|
|
623 |
$(".create-or-edit").text(addMode ? "Créer un nouveau segment" : "Modifier le segment"); |
|
39
|
624 |
updateSegmentUI(); |
|
27
|
625 |
media.show(); |
|
|
626 |
$("#segment-title").val(currentSegment.title); |
|
|
627 |
$("#segment-description").val(currentSegment.description); |
|
|
628 |
$("#segment-tags").val(""); |
|
29
|
629 |
var relatedSegments = mashup.segments.filter(function(_s) { |
|
|
630 |
return _s.getMedia() === currentMedia && _s.annotation !== currentSegment; |
|
|
631 |
}); |
|
|
632 |
var html = ""; |
|
|
633 |
if (relatedSegments.length) { |
|
|
634 |
var k = $(".Ldt-Slider").width() / currentSegment.getMedia().duration, |
|
|
635 |
currentleft = k * currentSegment.begin, |
|
|
636 |
currentwidth = k * currentSegment.getDuration(); |
|
|
637 |
relatedSegments.forEach(function(_s) { |
|
|
638 |
var pos = k * (_s.annotation.begin + _s.annotation.end) / 2, |
|
|
639 |
corrpos = Math.max(145, Math.min(305, pos)); |
|
|
640 |
vizdata = { |
|
|
641 |
annotation : _s.annotation, |
|
|
642 |
currentleft : currentleft, |
|
|
643 |
currentwidth : currentwidth, |
|
|
644 |
popleft : corrpos, |
|
|
645 |
left : k * _s.annotation.begin, |
|
|
646 |
width : k * _s.annotation.getDuration(), |
|
|
647 |
pointerpos : (pos - corrpos) |
|
|
648 |
} |
|
|
649 |
html += mediasegmenttemplate(vizdata); |
|
|
650 |
}); |
|
|
651 |
$(".self-media-segments").show(); |
|
|
652 |
} else { |
|
|
653 |
$(".self-media-segments").hide(); |
|
|
654 |
} |
|
22
|
655 |
} |
|
29
|
656 |
$(".self-media-segments .media-segments-list").html(html); |
|
27
|
657 |
if (currentMedia.elementType === "mashup") { |
|
|
658 |
showPreview(); |
|
|
659 |
mashup.checkLoaded(); |
|
|
660 |
} |
|
23
|
661 |
$(".Ldt-Ctrl-Time-Total").text(currentMedia.duration.toString()); |
|
25
|
662 |
// TODO: Do something with the tags ! |
|
23
|
663 |
onCurrentMediaTimeupdate(currentMedia.getCurrentTime()); |
|
|
664 |
onCurrentMediaPause(); |
|
27
|
665 |
highlightCurrentSegment(); |
|
22
|
666 |
} |
|
|
667 |
|
|
|
668 |
function addMediaPlayer(media) { |
|
23
|
669 |
var videoid = "video_" + media.id, |
|
|
670 |
videoEl = $('<video>'), |
|
|
671 |
width = $(".video").width(), |
|
|
672 |
height = $(".video").height(), |
|
|
673 |
mp4_file = media.video.replace(/\.webm$/i,'.mp4'), |
|
|
674 |
webm_file = media.video.replace(/\.mp4$/i,'.webm'), |
|
|
675 |
mp4_src = $('<source>'), |
|
|
676 |
webm_src = $('<source>'); |
|
|
677 |
mp4_src.attr({ |
|
|
678 |
src: mp4_file, |
|
|
679 |
type: "video/mp4" |
|
|
680 |
}); |
|
|
681 |
webm_src.attr({ |
|
|
682 |
src: webm_file, |
|
|
683 |
type: "video/webm" |
|
|
684 |
}); |
|
|
685 |
videoEl.attr({ |
|
|
686 |
id : videoid, |
|
|
687 |
width : width, |
|
|
688 |
height : height |
|
|
689 |
}).css({ |
|
|
690 |
position : "absolute", |
|
|
691 |
left: 0, |
|
|
692 |
top: 0, |
|
|
693 |
width : width, |
|
|
694 |
height : height |
|
|
695 |
}); |
|
|
696 |
videoEl.append(mp4_src).append(webm_src); |
|
|
697 |
$(".video").append(videoEl); |
|
27
|
698 |
|
|
|
699 |
media.show = function() { |
|
|
700 |
videoEl.show(); |
|
|
701 |
} |
|
|
702 |
media.hide = function() { |
|
|
703 |
videoEl.hide(); |
|
|
704 |
} |
|
|
705 |
|
|
23
|
706 |
var popcorn = Popcorn("#" + videoid); |
|
|
707 |
|
|
|
708 |
// Binding functions to Popcorn |
|
|
709 |
|
|
|
710 |
media.on("setcurrenttime", function(_milliseconds) { |
|
27
|
711 |
if (media.loaded) { |
|
|
712 |
popcorn.currentTime(_milliseconds / 1000); |
|
|
713 |
} |
|
23
|
714 |
}); |
|
|
715 |
|
|
|
716 |
media.on("setvolume", function(_vol) { |
|
|
717 |
media.volume = _vol; |
|
27
|
718 |
if (media.loaded) { |
|
|
719 |
popcorn.volume(_vol); |
|
|
720 |
} |
|
23
|
721 |
}); |
|
|
722 |
|
|
|
723 |
media.on("setmuted", function(_muted) { |
|
|
724 |
media.muted = _muted; |
|
27
|
725 |
if (media.loaded) { |
|
|
726 |
popcorn.muted(_muted); |
|
|
727 |
} |
|
23
|
728 |
}); |
|
|
729 |
|
|
|
730 |
media.on("setplay", function() { |
|
27
|
731 |
if (media.loaded) { |
|
|
732 |
popcorn.play(); |
|
|
733 |
} |
|
23
|
734 |
}); |
|
|
735 |
|
|
|
736 |
media.on("setpause", function() { |
|
27
|
737 |
if (media.loaded) { |
|
|
738 |
popcorn.pause(); |
|
|
739 |
} |
|
23
|
740 |
}); |
|
|
741 |
|
|
|
742 |
// Binding Popcorn events to media |
|
|
743 |
|
|
|
744 |
function getVolume() { |
|
|
745 |
media.muted = popcorn.muted(); |
|
|
746 |
media.volume = popcorn.volume(); |
|
|
747 |
} |
|
|
748 |
|
|
|
749 |
popcorn.on("loadedmetadata", function() { |
|
|
750 |
getVolume(); |
|
27
|
751 |
media.loaded = true; |
|
23
|
752 |
media.trigger("loadedmetadata"); |
|
|
753 |
media.trigger("volumechange"); |
|
|
754 |
}) |
|
|
755 |
|
|
|
756 |
popcorn.on("timeupdate", function() { |
|
|
757 |
media.trigger("timeupdate", new IriSP.Model.Time(1000*popcorn.currentTime())); |
|
|
758 |
}); |
|
|
759 |
|
|
|
760 |
popcorn.on("volumechange", function() { |
|
|
761 |
getVolume(); |
|
|
762 |
media.trigger("volumechange"); |
|
|
763 |
}) |
|
|
764 |
|
|
|
765 |
popcorn.on("play", function() { |
|
|
766 |
media.trigger("play"); |
|
|
767 |
}); |
|
|
768 |
|
|
|
769 |
popcorn.on("pause", function() { |
|
|
770 |
media.trigger("pause"); |
|
|
771 |
}); |
|
|
772 |
|
|
|
773 |
popcorn.on("seeked", function() { |
|
|
774 |
media.trigger("seeked"); |
|
|
775 |
}); |
|
|
776 |
|
|
27
|
777 |
// Binding UI Events and Mashup Playing to Media |
|
|
778 |
|
|
|
779 |
media.on("loadedmetadata", function() { |
|
32
|
780 |
if (media === currentMedia) { |
|
|
781 |
seekdiv.hide(); |
|
|
782 |
} |
|
27
|
783 |
mashup.checkLoaded(); |
|
|
784 |
}); |
|
23
|
785 |
|
|
|
786 |
media.on("play", function() { |
|
|
787 |
if (media === currentMedia) { |
|
|
788 |
onCurrentMediaPlay(); |
|
|
789 |
} |
|
27
|
790 |
if (mashup === currentMedia && media === mashupCurrentMedia) { |
|
|
791 |
mashup.trigger("play"); |
|
|
792 |
} |
|
23
|
793 |
}); |
|
|
794 |
|
|
|
795 |
media.on("pause", function() { |
|
|
796 |
if (media === currentMedia) { |
|
|
797 |
onCurrentMediaPause(); |
|
|
798 |
} |
|
27
|
799 |
if (mashup === currentMedia && media === mashupCurrentMedia) { |
|
|
800 |
mashup.trigger("pause"); |
|
|
801 |
} |
|
23
|
802 |
}); |
|
|
803 |
|
|
|
804 |
media.on("timeupdate", function(_time) { |
|
|
805 |
if (media === currentMedia) { |
|
|
806 |
onCurrentMediaTimeupdate(_time); |
|
|
807 |
} |
|
27
|
808 |
if (mashup === currentMedia && !mashup.paused && media === mashupCurrentMedia && !media.seeking) { |
|
|
809 |
if ( _time < mashupSegmentEnd ) { |
|
|
810 |
if ( _time >= mashupSegmentBegin ) { |
|
|
811 |
mashupTimecode = _time - mashupTimedelta; |
|
|
812 |
} else { |
|
|
813 |
mashupTimecode = mashupSegmentBegin - mashupTimedelta; |
|
|
814 |
media.setCurrentTime(mashupSegmentBegin); |
|
|
815 |
} |
|
|
816 |
} else { |
|
|
817 |
mashupTimecode = mashupSegmentEnd - mashupTimedelta; |
|
|
818 |
media.pause(); |
|
|
819 |
changeCurrentAnnotation(); |
|
|
820 |
} |
|
|
821 |
mashup.trigger("timeupdate", new IriSP.Model.Time(mashupTimecode)); |
|
|
822 |
} |
|
|
823 |
}); |
|
|
824 |
|
|
|
825 |
media.on("seeked", function() { |
|
|
826 |
media.seeking = false; |
|
|
827 |
if (mashup === currentMedia && media === mashupCurrentMedia && mashupSeeking) { |
|
|
828 |
mashupSeeking = false; |
|
32
|
829 |
seekdiv.hide(); |
|
27
|
830 |
} |
|
25
|
831 |
}); |
|
|
832 |
|
|
|
833 |
media.on("volumechange", function() { |
|
|
834 |
if (media === currentMedia) { |
|
|
835 |
ctrlVolumeUpdater(); |
|
|
836 |
} |
|
27
|
837 |
mashup.muted = media.muted; |
|
|
838 |
mashup.volume = media.volume; |
|
|
839 |
mashup.trigger("volumechange"); |
|
23
|
840 |
}) |
|
18
|
841 |
|
|
13
|
842 |
} |
|
27
|
843 |
|
|
|
844 |
// Mashup Events |
|
25
|
845 |
|
|
27
|
846 |
mashup.on("setcurrenttime", function(_milliseconds) { |
|
|
847 |
mashupTimecode = _milliseconds; |
|
|
848 |
changeCurrentAnnotation(); |
|
|
849 |
}); |
|
|
850 |
|
|
|
851 |
mashup.on("setvolume", function(_vol) { |
|
|
852 |
mashup.getMedias().forEach(function(_media) { |
|
|
853 |
_media.setVolume(_vol); |
|
|
854 |
}); |
|
|
855 |
mashup.volume = _vol; |
|
|
856 |
}); |
|
|
857 |
|
|
|
858 |
mashup.on("setmuted", function(_muted) { |
|
|
859 |
mashup.getMedias().forEach(function(_media) { |
|
|
860 |
_media.setMuted(_muted); |
|
|
861 |
}); |
|
|
862 |
mashup.muted = _muted; |
|
|
863 |
}); |
|
|
864 |
|
|
|
865 |
mashup.on("setplay", function() { |
|
|
866 |
mashup.paused = false; |
|
|
867 |
changeCurrentAnnotation(); |
|
|
868 |
}); |
|
|
869 |
|
|
|
870 |
mashup.on("setpause", function() { |
|
|
871 |
mashup.paused = true; |
|
|
872 |
if (mashupCurrentMedia) { |
|
|
873 |
mashupCurrentMedia.pause(); |
|
|
874 |
} |
|
|
875 |
}); |
|
|
876 |
|
|
|
877 |
mashup.on("loadedmetadata", function() { |
|
|
878 |
if (mashup === currentMedia) { |
|
|
879 |
changeCurrentAnnotation(); |
|
|
880 |
} |
|
|
881 |
}); |
|
|
882 |
|
|
|
883 |
/* Mashup Events to UI */ |
|
|
884 |
|
|
|
885 |
mashup.on("play", function() { |
|
|
886 |
if (mashup === currentMedia) { |
|
|
887 |
onCurrentMediaPlay(); |
|
|
888 |
} |
|
|
889 |
}); |
|
|
890 |
|
|
|
891 |
mashup.on("pause", function() { |
|
|
892 |
if (mashup === currentMedia) { |
|
|
893 |
onCurrentMediaPause(); |
|
|
894 |
} |
|
|
895 |
}); |
|
|
896 |
|
|
|
897 |
mashup.on("timeupdate", function(_time) { |
|
|
898 |
if (mashup === currentMedia) { |
|
|
899 |
$(".frise-position").css("left",(100*_time/mashup.duration)+"%"); |
|
|
900 |
onCurrentMediaTimeupdate(_time); |
|
|
901 |
} |
|
|
902 |
}); |
|
|
903 |
|
|
25
|
904 |
/* Segment Form interaction */ |
|
|
905 |
|
|
|
906 |
$("#segment-title").on("keyup change input paste", function() { |
|
27
|
907 |
if (currentMedia && currentSegment) { |
|
|
908 |
currentSegment.title = $(this).val(); |
|
39
|
909 |
updateSegmentUI(); |
|
27
|
910 |
updateMashupUI(); |
|
25
|
911 |
} |
|
|
912 |
}); |
|
|
913 |
$("#segment-description").on("keyup change input paste", function() { |
|
27
|
914 |
if (currentMedia && currentSegment) { |
|
|
915 |
currentSegment.description = $(this).val(); |
|
39
|
916 |
updateSegmentUI(); |
|
25
|
917 |
} |
|
|
918 |
}); |
|
|
919 |
$("#segment-form").submit(function() { |
|
27
|
920 |
if (addMode) { |
|
|
921 |
mashup.addAnnotation(currentSegment); |
|
|
922 |
} else { |
|
|
923 |
updateMashupUI(); |
|
|
924 |
} |
|
|
925 |
var segment = mashup.getAnnotation(currentSegment); |
|
|
926 |
currentSegment = undefined; |
|
|
927 |
setMedia(mashup); |
|
|
928 |
if (segment) { |
|
|
929 |
mashup.setCurrentTime(segment.begin); |
|
|
930 |
} |
|
29
|
931 |
return false; |
|
25
|
932 |
}) |
|
|
933 |
|
|
22
|
934 |
/* Click on media items */ |
|
|
935 |
|
|
|
936 |
$(".col-left").on("click", ".item-video", function() { |
|
27
|
937 |
currentSegment = undefined; |
|
|
938 |
setMedia(project.getElement($(this).attr("data-media-id"))); |
|
22
|
939 |
}); |
|
12
|
940 |
|
|
22
|
941 |
/* Click on Tabs */ |
|
|
942 |
|
|
|
943 |
function showSegmentation() { |
|
|
944 |
$(".col-middle").removeClass("empty-mode pvw-mode").addClass("segment-mode"); |
|
|
945 |
return false; |
|
|
946 |
} |
|
|
947 |
function showPreview() { |
|
|
948 |
$(".col-middle").removeClass("empty-mode segment-mode").addClass("pvw-mode"); |
|
|
949 |
return false; |
|
|
950 |
} |
|
32
|
951 |
function showEmpty() { |
|
|
952 |
$("video").hide(); |
|
|
953 |
$(".col-middle").removeClass("pvw-mode segment-mode").addClass("empty-mode"); |
|
|
954 |
return false; |
|
|
955 |
} |
|
22
|
956 |
|
|
27
|
957 |
$(".tab-pvw").click(function() { |
|
|
958 |
if (mashup.segments.length) { |
|
|
959 |
setMedia(mashup); |
|
22
|
960 |
} |
|
|
961 |
}); |
|
|
962 |
|
|
27
|
963 |
/* Click on segments */ |
|
|
964 |
|
|
|
965 |
function reorganizeMashup() { |
|
|
966 |
var ids = $(".organize-segments .item-video").map(function(){return $(this).attr("data-segment-id")}); |
|
|
967 |
mashup.setAnnotationsById(ids); |
|
|
968 |
} |
|
|
969 |
|
|
|
970 |
function highlightCurrentSegment() { |
|
32
|
971 |
$(".organize-segments .item-video, .col-left .item-video, .frise-segment").removeClass("active"); |
|
|
972 |
var segmentid = undefined; |
|
27
|
973 |
if (currentMedia && currentSegment) { |
|
32
|
974 |
segmentid = currentSegment.id; |
|
|
975 |
} |
|
|
976 |
if (currentMedia === mashup && mashupCurrentAnnotation) { |
|
|
977 |
segmentid = mashupCurrentAnnotation.annotation.id; |
|
27
|
978 |
} |
|
32
|
979 |
$(".item-video[data-segment-id='" + segmentid + "']").addClass("active"); |
|
|
980 |
var mediaid = undefined; |
|
|
981 |
if (currentMedia) { |
|
|
982 |
mediaid = currentMedia.id; |
|
|
983 |
} |
|
|
984 |
if (currentMedia === mashup && mashupCurrentMedia) { |
|
|
985 |
mediaid = mashupCurrentMedia.id |
|
|
986 |
} |
|
|
987 |
$(".col-left .item-video[data-media-id='" + mediaid + "']").addClass("active"); |
|
27
|
988 |
} |
|
|
989 |
|
|
32
|
990 |
function hoverSegment() { |
|
|
991 |
var segmentid = $(this).attr("data-segment-id"); |
|
|
992 |
$(".organize-segments .item-video, .frise-segment").removeClass("active"); |
|
|
993 |
$(".item-video[data-segment-id='" + segmentid + "'], .frise-segment[data-segment-id='" + segmentid + "']").addClass("active"); |
|
|
994 |
} |
|
|
995 |
|
|
|
996 |
$(".frise") |
|
|
997 |
.on("mouseover", ".frise-segment", hoverSegment) |
|
|
998 |
.on("mouseout", ".frise-segment", highlightCurrentSegment) |
|
|
999 |
|
|
|
1000 |
$(".organize-segments") |
|
|
1001 |
.sortable({ |
|
27
|
1002 |
stop : reorganizeMashup |
|
32
|
1003 |
}) |
|
|
1004 |
.on("mouseover", ".item-video", hoverSegment) |
|
|
1005 |
.on("mouseout", ".item-video", highlightCurrentSegment) |
|
|
1006 |
.on("click", ".item-video", function(e) { |
|
27
|
1007 |
var el = $(this), |
|
|
1008 |
segment = mashup.getAnnotationById(el.attr("data-segment-id")); |
|
|
1009 |
setMedia(mashup); |
|
|
1010 |
if (segment) { |
|
|
1011 |
mashup.setCurrentTime(segment.begin); |
|
|
1012 |
} |
|
|
1013 |
return false; |
|
32
|
1014 |
}) |
|
|
1015 |
.on("click", ".edit", function(e) { |
|
27
|
1016 |
var currentItem = $(this).parents(".item-video"), |
|
|
1017 |
media = project.getElement(currentItem.attr("data-media-id")), |
|
|
1018 |
segment = project.getElement(currentItem.attr("data-segment-id")); |
|
|
1019 |
currentSegment = segment; |
|
|
1020 |
setMedia(media); |
|
|
1021 |
return false; |
|
32
|
1022 |
}) |
|
|
1023 |
.on("click", ".top", function(e){ |
|
22
|
1024 |
var currentItem = $(this).parents(".item-video"); |
|
|
1025 |
currentItem.insertBefore(currentItem.prev()); |
|
27
|
1026 |
reorganizeMashup(); |
|
|
1027 |
return false; |
|
32
|
1028 |
}) |
|
|
1029 |
.on("click", ".bottom", function(e){ |
|
22
|
1030 |
var currentItem = $(this).parents(".item-video"); |
|
|
1031 |
currentItem.insertAfter(currentItem.next()); |
|
27
|
1032 |
reorganizeMashup(); |
|
|
1033 |
return false; |
|
32
|
1034 |
}) |
|
|
1035 |
.on("click", ".delete", function(e){ |
|
27
|
1036 |
var id = $(this).parents(".item-video").attr("data-segment-id"); |
|
|
1037 |
mashup.removeAnnotationById(id); |
|
32
|
1038 |
if (!mashup.segments.length) { |
|
|
1039 |
showEmpty(); |
|
|
1040 |
} |
|
27
|
1041 |
return false; |
|
22
|
1042 |
}); |
|
|
1043 |
|
|
25
|
1044 |
/* Tangles */ |
|
|
1045 |
var tangleMsPerPixel = 100, |
|
|
1046 |
activeTangle, |
|
23
|
1047 |
tangleStartX, |
|
25
|
1048 |
tangleStartVal, |
|
|
1049 |
tangleHasMoved; |
|
|
1050 |
|
|
23
|
1051 |
$(".time-tangle").mousedown(function(evt) { |
|
|
1052 |
activeTangle = $(this); |
|
|
1053 |
activeTangle.addClass("active"); |
|
|
1054 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
|
1055 |
tangleStartX = evt.pageX; |
|
25
|
1056 |
tangleHasMoved = false; |
|
|
1057 |
$(this).siblings(".time-tangle").addClass("deactivate"); |
|
23
|
1058 |
return false; |
|
|
1059 |
}); |
|
|
1060 |
$(document) |
|
|
1061 |
.mousemove(function(evt) { |
|
|
1062 |
if (activeTangle) { |
|
25
|
1063 |
tangleHasMoved = true; |
|
|
1064 |
var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
23
|
1065 |
activeTangle.trigger("valuechange", newval); |
|
|
1066 |
return false; |
|
|
1067 |
} |
|
|
1068 |
}) |
|
|
1069 |
.mouseup(function() { |
|
|
1070 |
if (activeTangle) { |
|
27
|
1071 |
activeTangle.text(activeTangle.text().replace(/\.\d+$/,'')); |
|
25
|
1072 |
$(".time-tangle").removeClass("active deactivate"); |
|
23
|
1073 |
activeTangle = undefined; |
|
|
1074 |
} |
|
25
|
1075 |
}); |
|
|
1076 |
|
|
|
1077 |
$(".tangle-start") |
|
|
1078 |
.mouseup(function(evt) { |
|
27
|
1079 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
|
|
1080 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
25
|
1081 |
} |
|
23
|
1082 |
}) |
|
25
|
1083 |
.on("valuechange", function(evt, val) { |
|
27
|
1084 |
if (currentMedia && currentSegment) { |
|
|
1085 |
currentSegment.setBegin(val); |
|
25
|
1086 |
} |
|
|
1087 |
}); |
|
|
1088 |
$(".tangle-end") |
|
|
1089 |
.mouseup(function(evt) { |
|
27
|
1090 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
|
|
1091 |
currentMedia.setCurrentTime(currentSegment.end); |
|
25
|
1092 |
} |
|
|
1093 |
}) |
|
|
1094 |
.on("valuechange", function(evt, val) { |
|
27
|
1095 |
if (currentMedia && currentSegment) { |
|
|
1096 |
currentSegment.setEnd(val); |
|
25
|
1097 |
} |
|
|
1098 |
}); |
|
|
1099 |
$(".tangle-duration").on("valuechange", function(evt, val) { |
|
27
|
1100 |
if (currentMedia && currentSegment) { |
|
|
1101 |
currentSegment.setDuration(val); |
|
25
|
1102 |
} |
|
|
1103 |
}); |
|
27
|
1104 |
|
|
29
|
1105 |
/* Click on current segment in Preview */ |
|
|
1106 |
|
|
27
|
1107 |
$(".mashup-description .edit").click(function() { |
|
|
1108 |
if (mashupCurrentAnnotation) { |
|
|
1109 |
currentSegment = mashupCurrentAnnotation.annotation; |
|
|
1110 |
setMedia(mashupCurrentAnnotation.getMedia()); |
|
|
1111 |
} |
|
29
|
1112 |
}); |
|
|
1113 |
|
|
|
1114 |
/* Handling related segments */ |
|
|
1115 |
|
|
|
1116 |
$(".media-segments-list").on("mouseover", ".media-segment", function() { |
|
|
1117 |
$(this).find(".media-segment-popin").show(); |
|
|
1118 |
}).on("mouseout", ".media-segment", function() { |
|
|
1119 |
$(this).find(".media-segment-popin").hide(); |
|
|
1120 |
}).on("click", ".reprendre-segment", function() { |
|
|
1121 |
var s = project.getElement($(this).attr("data-segment-id")); |
|
|
1122 |
currentSegment.title = s.title; |
|
|
1123 |
currentSegment.description = s.description; |
|
|
1124 |
$("#segment-title").val(s.title); |
|
|
1125 |
$("#segment-description").val(s.description); |
|
|
1126 |
currentSegment.setBegin(s.begin); |
|
|
1127 |
currentSegment.setEnd(s.end); |
|
|
1128 |
return false; |
|
|
1129 |
}); |
|
|
1130 |
|
|
32
|
1131 |
/* Changing Hashcut Title and description */ |
|
39
|
1132 |
|
|
|
1133 |
mashup.title = IriSP.hc_messages.mashup_title_placeholder; |
|
|
1134 |
$(".title-video-wrap a").text(mashup.title); |
|
|
1135 |
$("#hashcut-title").val(mashup.title); |
|
|
1136 |
|
|
32
|
1137 |
$("#hashcut-title").on("keyup change input paste", function() { |
|
|
1138 |
mashup.title = $(this).val(); |
|
|
1139 |
$(".title-video-wrap a").text(mashup.title); |
|
39
|
1140 |
updateMashupUI(); |
|
32
|
1141 |
}); |
|
|
1142 |
|
|
39
|
1143 |
$("#hashcut-description").on("keyup change input paste", function() { |
|
|
1144 |
mashup.description = $(this).val(); |
|
|
1145 |
updateMashupUI(); |
|
|
1146 |
}); |
|
|
1147 |
|
|
|
1148 |
updateMashupUI(); |
|
13
|
1149 |
} |