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