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