| author | veltr |
| Mon, 29 Oct 2012 18:11:09 +0100 | |
| changeset 26 | 7c394ea40f28 |
| parent 25 | eea45f9b124b |
| parent 24 | 1fbf7d835dc2 |
| child 27 | b2d068afdbd8 |
| permissions | -rw-r--r-- |
| 22 | 1 |
IriSP.Hashcut = function() { |
2 |
|
|
3 |
/* Load Media List */ |
|
4 |
|
|
5 |
var directory = new IriSP.Model.Directory(), |
|
6 |
project = directory.remoteSource({ |
|
7 |
url: "data/bpidata.json", |
|
8 |
serializer: IriSP.serializers.medialist |
|
9 |
}), |
|
| 25 | 10 |
mashup = new IriSP.Model.Mashup(false, project), |
| 22 | 11 |
mediatemplate = '<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>' |
|
| 25 | 13 |
+ '<span class="time-length">Durée : <span>{{duration}}</span></span></span></li>', |
14 |
segmenttemplate = '<li class="item-video" data-segment-id="{{id}}"><img src="{{annotation.thumbnail}}" alt="{{media_title}}" />' |
|
15 |
+ '<span class="video-info"><span class="title-video">{{media_title}}</span>' |
|
16 |
+ '<span class="subtitle">{{title}}</span><span class="duration">{{begin}} - {{end}} ({{duration}})</span>' |
|
17 |
+ '<ul class="tools"><li><a class="edit" href="#"></a></li><li><a class="bottom" href="#"></a></li>' |
|
18 |
+ '<li><a class="top" href="#"></a></li><li><a class="delete" href="#"></a></li></ul></span></li>'; |
|
| 22 | 19 |
|
20 |
/* Fill left column with Media List */ |
|
| 25 | 21 |
|
| 22 | 22 |
project.onLoad(function() { |
23 |
var html = ''; |
|
24 |
project.getMedias().forEach(function(_m) { |
|
25 |
html += Mustache.to_html(mediatemplate, _m); |
|
| 13 | 26 |
}); |
| 22 | 27 |
$(".col-left .list-video").html(html); |
28 |
}); |
|
29 |
|
|
30 |
/* Search Media with left column form */ |
|
31 |
|
|
32 |
$(".col-left input").on("keyup change input paste", function() { |
|
33 |
var val = $(this).val(); |
|
34 |
if (val) { |
|
35 |
var find = IriSP.Model.regexpFromTextOrArray(val, true), |
|
36 |
replace = IriSP.Model.regexpFromTextOrArray(val, false); |
|
37 |
} |
|
38 |
$(".col-left .item-video").each(function() { |
|
39 |
var li = $(this), |
|
40 |
title = $(this).find(".title-video"), |
|
41 |
titletext = title.text(); |
|
42 |
if (val && find.test(titletext)) { |
|
43 |
title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>')); |
|
44 |
li.show(); |
|
45 |
} else { |
|
46 |
title.text(titletext); |
|
47 |
if (val) { |
|
48 |
li.hide(); |
|
| 13 | 49 |
} else { |
| 22 | 50 |
li.show(); |
| 13 | 51 |
} |
| 22 | 52 |
} |
53 |
}) |
|
54 |
}); |
|
55 |
|
|
| 25 | 56 |
/* Fill right column when mashup is updated */ |
57 |
|
|
58 |
function fillRightColumn() { |
|
59 |
var html = ''; |
|
60 |
mashup.segments.forEach(function(_s) { |
|
61 |
html += Mustache.to_html(segmenttemplate, _s); |
|
62 |
}); |
|
63 |
$(".col-right .list-video").html(html); |
|
64 |
} |
|
65 |
|
|
66 |
mashup.on("add-segments",fillRightColumn); |
|
67 |
|
|
| 22 | 68 |
/* Slider */ |
69 |
|
|
| 23 | 70 |
var timeSlider = $(".Ldt-Slider"), |
71 |
slidersRange = 920; |
|
| 22 | 72 |
timeSlider.slider({ |
73 |
range: "min", |
|
74 |
value: 0, |
|
75 |
min: 0, |
|
| 23 | 76 |
max: slidersRange, |
| 22 | 77 |
slide: function(event, ui) { |
| 23 | 78 |
if (currentMedia) { |
79 |
var t = currentMedia.duration * ui.value / slidersRange; |
|
80 |
currentMedia.setCurrentTime(t); |
|
81 |
} |
|
| 22 | 82 |
} |
83 |
}); |
|
84 |
|
|
85 |
var timeSliderHandle = timeSlider.find('.ui-slider-handle'), |
|
86 |
timeSliderMaximized = false, |
|
87 |
timeSliderTimeoutId = false, |
|
88 |
timeSliderMinimizedHeight = 4, |
|
89 |
timeSliderMaximizedHeight = 10, |
|
90 |
timeSliderTimeoutDuration = 1500, |
|
91 |
timeTooltip = $(".Ldt-Slider-Time"); |
|
92 |
|
|
93 |
timeSlider.css(calculateSliderCss(timeSliderMinimizedHeight)); |
|
94 |
timeSliderHandle.css(calculateHandleCss(timeSliderMinimizedHeight)); |
|
95 |
|
|
96 |
function timeSliderMouseOver() { |
|
97 |
if (timeSliderTimeoutId) { |
|
98 |
window.clearTimeout(timeSliderTimeoutId); |
|
99 |
timeSliderTimeoutId = false; |
|
100 |
} |
|
101 |
if (!timeSliderMaximized) { |
|
102 |
timeSliderAnimateToHeight(timeSliderMaximizedHeight); |
|
103 |
timeSliderMaximized = true; |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
function timeSliderMouseOut() { |
|
108 |
timeTooltip.hide(); |
|
109 |
if (timeSliderTimeoutId) { |
|
110 |
clearTimeout(timeSliderTimeoutId); |
|
111 |
timeSliderTimeoutId = false; |
|
112 |
} |
|
113 |
timeSliderTimeoutId = setTimeout(function() { |
|
114 |
if (timeSliderMaximized) { |
|
115 |
timeSliderAnimateToHeight(timeSliderMinimizedHeight); |
|
116 |
timeSliderMaximized = false; |
|
117 |
} |
|
118 |
timeSliderTimeoutId = false; |
|
119 |
}, timeSliderTimeoutDuration); |
|
120 |
} |
|
121 |
|
|
122 |
timeSlider |
|
123 |
.mouseover(function() { |
|
124 |
timeTooltip.show(); |
|
125 |
timeSliderMouseOver(); |
|
126 |
}) |
|
127 |
.mouseout(timeSliderMouseOut) |
|
128 |
.mousemove(function(_e) { |
|
129 |
var _x = _e.pageX - timeSlider.offset().left, |
|
| 23 | 130 |
_t = new IriSP.Model.Time( |
131 |
currentMedia ? currentMedia.duration * _x / timeSlider.width() : 0 |
|
132 |
); |
|
| 22 | 133 |
timeTooltip.text(_t.toString()).css("left",_x); |
| 15 | 134 |
}); |
| 22 | 135 |
|
136 |
$(".Ldt-Ctrl").mouseover(timeSliderMouseOver).mouseout(timeSliderMouseOut); |
|
137 |
|
|
138 |
function timeSliderAnimateToHeight(_height) { |
|
139 |
timeSlider.stop().animate( |
|
140 |
calculateSliderCss(_height), |
|
141 |
500, |
|
142 |
function() { |
|
143 |
IriSP.jQuery(this).css("overflow","visible"); |
|
144 |
}); |
|
145 |
timeSliderHandle.stop().animate( |
|
146 |
calculateHandleCss(_height), |
|
147 |
500, |
|
148 |
function() { |
|
149 |
IriSP.jQuery(this).css("overflow","visible"); |
|
150 |
}); |
|
151 |
} |
|
152 |
||
153 |
function calculateSliderCss(_size) { |
|
154 |
return { |
|
155 |
height: _size + "px", |
|
156 |
"margin-top": (timeSliderMinimizedHeight - _size) + "px" |
|
157 |
}; |
|
158 |
} |
|
159 |
||
160 |
function calculateHandleCss(_size) { |
|
161 |
return { |
|
162 |
height: (2 + _size) + "px", |
|
163 |
width: (2 + _size) + "px", |
|
164 |
"margin-left": -Math.ceil(2 + _size / 2) + "px" |
|
| 18 | 165 |
} |
| 22 | 166 |
} |
167 |
|
|
168 |
/* Controller Widget */ |
|
169 |
|
|
170 |
var volBlock = $(".Ldt-Ctrl-Volume-Control"); |
|
| 25 | 171 |
|
| 22 | 172 |
$('.Ldt-Ctrl-Sound') |
| 25 | 173 |
.click(function() { |
174 |
if (currentMedia) { |
|
175 |
currentMedia.setMuted(!currentMedia.getMuted()); |
|
176 |
} |
|
177 |
}) |
|
| 22 | 178 |
.mouseover(function() { |
179 |
volBlock.show(); |
|
180 |
}) |
|
181 |
.mouseout(function() { |
|
182 |
volBlock.hide(); |
|
| 18 | 183 |
}); |
| 22 | 184 |
volBlock.mouseover(function() { |
185 |
volBlock.show(); |
|
186 |
}).mouseout(function() { |
|
187 |
volBlock.hide(); |
|
188 |
}); |
|
189 |
|
|
190 |
var volBar = $(".Ldt-Ctrl-Volume-Bar"); |
|
| 25 | 191 |
|
192 |
function ctrlVolumeUpdater() { |
|
193 |
if (currentMedia) { |
|
194 |
var _muted = currentMedia.getMuted(), |
|
195 |
_vol = currentMedia.getVolume(); |
|
196 |
if (_vol === false) { |
|
197 |
_vol = .5; |
|
198 |
} |
|
199 |
var _soundCtl = $(".Ldt-Ctrl-Sound"); |
|
200 |
_soundCtl.removeClass("Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full"); |
|
201 |
if (_muted) { |
|
202 |
_soundCtl.attr("title", "Activer le son") |
|
203 |
.addClass("Ldt-Ctrl-Sound-Mute"); |
|
204 |
} else { |
|
205 |
_soundCtl.attr("title", "Couper le son") |
|
206 |
.addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" ) |
|
207 |
} |
|
208 |
volBar.slider("value", _muted ? 0 : 100 * _vol); |
|
209 |
volBar.attr("title",'Volume : ' + Math.floor(100 * _vol) + '%'); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
| 22 | 213 |
volBar.slider({ |
214 |
slide: function(event, ui) { |
|
| 25 | 215 |
if (currentMedia) { |
216 |
currentMedia.setVolume(ui.value / 100); |
|
217 |
} |
|
| 22 | 218 |
} |
219 |
}); |
|
220 |
|
|
| 23 | 221 |
$(".Ldt-Ctrl-Play").click(function() { |
222 |
if (currentMedia) { |
|
223 |
if (currentMedia.getPaused()) { |
|
224 |
currentMedia.play(); |
|
225 |
} else { |
|
226 |
currentMedia.pause(); |
|
227 |
} |
|
228 |
} |
|
229 |
}); |
|
230 |
|
|
| 25 | 231 |
$(".Ldt-Ctrl-SetIn").click(function() { |
232 |
if (currentMedia && currentMedia.currentSegment) { |
|
233 |
currentMedia.currentSegment.setBegin(currentMedia.getCurrentTime()); |
|
234 |
} |
|
235 |
}); |
|
236 |
$(".Ldt-Ctrl-SetOut").click(function() { |
|
237 |
if (currentMedia && currentMedia.currentSegment) { |
|
238 |
currentMedia.currentSegment.setEnd(currentMedia.getCurrentTime()); |
|
239 |
} |
|
240 |
}); |
|
241 |
|
|
| 23 | 242 |
/* Slice Widget */ |
| 25 | 243 |
|
| 23 | 244 |
var sliceSlider = $(".Ldt-Slice"), |
245 |
sliceStartTime; |
|
246 |
|
|
247 |
sliceSlider.slider({ |
|
248 |
range: true, |
|
249 |
values: [0, slidersRange], |
|
250 |
min: 0, |
|
251 |
max: slidersRange, |
|
252 |
start: function() { |
|
253 |
if (currentMedia) { |
|
254 |
if (!currentMedia.getPaused()) { |
|
255 |
currentMedia.pause(); |
|
256 |
} |
|
257 |
} |
|
258 |
}, |
|
259 |
slide: function(event, ui) { |
|
| 25 | 260 |
if (currentMedia && currentMedia.currentSegment) { |
| 23 | 261 |
var t = currentMedia.duration * ui.value / slidersRange; |
| 25 | 262 |
if (ui.value === ui.values[0]) { |
263 |
currentMedia.currentSegment.setBegin(t); |
|
264 |
} else { |
|
265 |
currentMedia.currentSegment.setEnd(t); |
|
266 |
} |
|
| 23 | 267 |
} |
268 |
} |
|
269 |
}); |
|
270 |
|
|
| 25 | 271 |
sliceSlider.find(".ui-slider-handle:first") |
272 |
.addClass("Ldt-Slice-left-handle") |
|
273 |
.click(function() { |
|
274 |
if (currentMedia && currentMedia.currentSegment) { |
|
275 |
currentMedia.setCurrentTime(currentMedia.currentSegment.begin); |
|
276 |
} |
|
277 |
}); |
|
278 |
sliceSlider.find(".ui-slider-handle:last") |
|
279 |
.addClass("Ldt-Slice-right-handle") |
|
280 |
.click(function() { |
|
281 |
if (currentMedia && currentMedia.currentSegment) { |
|
282 |
currentMedia.setCurrentTime(currentMedia.currentSegment.end); |
|
283 |
} |
|
284 |
}); |
|
| 23 | 285 |
|
286 |
/* UI Events */ |
|
287 |
||
288 |
function onCurrentMediaPlay() { |
|
289 |
$(".Ldt-Ctrl-Play") |
|
290 |
.attr("title", "Pause") |
|
291 |
.removeClass("Ldt-Ctrl-Play-PlayState") |
|
292 |
.addClass("Ldt-Ctrl-Play-PauseState") |
|
293 |
} |
|
294 |
|
|
295 |
function onCurrentMediaPause() { |
|
296 |
$(".Ldt-Ctrl-Play") |
|
297 |
.attr("title", "Lecture") |
|
298 |
.removeClass("Ldt-Ctrl-Play-PauseState") |
|
299 |
.addClass("Ldt-Ctrl-Play-PlayState") |
|
300 |
} |
|
301 |
|
|
302 |
function onCurrentMediaTimeupdate(_time) { |
|
303 |
$(".Ldt-Ctrl-Time-Elapsed").text(_time.toString()); |
|
304 |
timeSlider.slider("value",slidersRange * _time / currentMedia.duration); |
|
305 |
} |
|
306 |
|
|
| 22 | 307 |
/* Set current Media */ |
| 25 | 308 |
|
| 22 | 309 |
var currentMedia; |
310 |
|
|
| 25 | 311 |
function updateSliderAndTangles() { |
312 |
if (currentMedia && currentMedia.currentSegment) { |
|
313 |
var start = currentMedia.currentSegment.begin, |
|
314 |
end = currentMedia.currentSegment.end, |
|
315 |
dur = currentMedia.currentSegment.getDuration(), |
|
316 |
f = slidersRange / currentMedia.duration; |
|
317 |
sliceSlider.slider( "values", [ f * start, f * end ] ); |
|
318 |
$(".tangle-start").text(start.toString()).attr("data-milliseconds",start.milliseconds); |
|
319 |
$(".tangle-end").text(end.toString()).attr("data-milliseconds",end.milliseconds); |
|
320 |
$(".tangle-duration").text(dur.toString()).attr("data-milliseconds",dur.milliseconds); |
|
321 |
$(".segment-info .pointer").css("left",(parseFloat($(".Ldt-Slice-left-handle").css("left")) + parseFloat($(".Ldt-Slice-right-handle").css("left")))/2) |
|
322 |
} |
|
323 |
} |
|
324 |
|
|
| 22 | 325 |
function setMedia(mediaid) { |
| 23 | 326 |
$(".col-left .item-video").removeClass("active"); |
327 |
$(".tutorial").hide(); |
|
328 |
$("video").hide(); |
|
329 |
if (currentMedia) { |
|
330 |
currentMedia.pause(); |
|
331 |
} |
|
| 22 | 332 |
currentMedia = project.getElement(mediaid); |
333 |
if (currentMedia.elementType == "media") { |
|
| 23 | 334 |
$(".col-left .item-video[data-media-id='" + mediaid + "']").addClass("active"); |
335 |
showSegmentation(); |
|
336 |
var currentvideo = $('#video_' + mediaid); |
|
337 |
if (!currentvideo.length) { |
|
338 |
addMediaPlayer(currentMedia); |
|
339 |
currentvideo = $('#video_' + mediaid); |
|
340 |
} |
|
341 |
$(".tab-media-title").text(currentMedia.title); |
|
| 25 | 342 |
if (!currentMedia.currentSegment) { |
343 |
currentMedia.currentSegment = new IriSP.Model.Annotation(false, project); |
|
344 |
currentMedia.currentSegment.setMedia(currentMedia.id); |
|
345 |
currentMedia.currentSegment.setBegin(0); |
|
346 |
currentMedia.currentSegment.setEnd(currentMedia.duration); |
|
347 |
currentMedia.currentSegment.thumbnail = currentMedia.thumbnail; |
|
348 |
currentMedia.currentSegment.title = "Segment sans titre"; |
|
349 |
currentMedia.currentSegment.description = "Extrait de « " + currentMedia.title + " »"; |
|
350 |
currentMedia.currentSegment.on("change-begin", function() { |
|
351 |
if (currentMedia && currentMedia.currentSegment === this) { |
|
352 |
currentMedia.setCurrentTime(this.begin); |
|
353 |
updateSliderAndTangles(); |
|
354 |
} |
|
355 |
}); |
|
356 |
currentMedia.currentSegment.on("change-end", function() { |
|
357 |
if (currentMedia && currentMedia.currentSegment === this) { |
|
358 |
currentMedia.setCurrentTime(this.end); |
|
359 |
updateSliderAndTangles(); |
|
360 |
} |
|
361 |
}); |
|
362 |
} |
|
363 |
updateSliderAndTangles(); |
|
| 22 | 364 |
} |
| 23 | 365 |
currentvideo.show(); |
366 |
$(".Ldt-Ctrl-Time-Total").text(currentMedia.duration.toString()); |
|
| 25 | 367 |
$("#segment-title").val(currentMedia.currentSegment.title); |
368 |
$("#segment-description").text(currentMedia.currentSegment.description); |
|
369 |
// TODO: Do something with the tags ! |
|
| 23 | 370 |
onCurrentMediaTimeupdate(currentMedia.getCurrentTime()); |
371 |
onCurrentMediaPause(); |
|
| 22 | 372 |
} |
373 |
|
|
374 |
function addMediaPlayer(media) { |
|
| 23 | 375 |
var videoid = "video_" + media.id, |
376 |
videoEl = $('<video>'), |
|
377 |
width = $(".video").width(), |
|
378 |
height = $(".video").height(), |
|
379 |
mp4_file = media.video.replace(/\.webm$/i,'.mp4'), |
|
380 |
webm_file = media.video.replace(/\.mp4$/i,'.webm'), |
|
381 |
mp4_src = $('<source>'), |
|
382 |
webm_src = $('<source>'); |
|
383 |
mp4_src.attr({ |
|
384 |
src: mp4_file, |
|
385 |
type: "video/mp4" |
|
386 |
}); |
|
387 |
webm_src.attr({ |
|
388 |
src: webm_file, |
|
389 |
type: "video/webm" |
|
390 |
}); |
|
391 |
videoEl.attr({ |
|
392 |
id : videoid, |
|
393 |
width : width, |
|
394 |
height : height |
|
395 |
}).css({ |
|
396 |
position : "absolute", |
|
397 |
left: 0, |
|
398 |
top: 0, |
|
399 |
width : width, |
|
400 |
height : height |
|
401 |
}); |
|
402 |
videoEl.append(mp4_src).append(webm_src); |
|
403 |
$(".video").append(videoEl); |
|
404 |
||
405 |
var popcorn = Popcorn("#" + videoid); |
|
406 |
|
|
407 |
// Binding functions to Popcorn |
|
408 |
|
|
409 |
media.on("setcurrenttime", function(_milliseconds) { |
|
410 |
popcorn.currentTime(_milliseconds / 1000); |
|
411 |
}); |
|
412 |
|
|
413 |
media.on("setvolume", function(_vol) { |
|
414 |
popcorn.volume(_vol); |
|
415 |
media.volume = _vol; |
|
416 |
}); |
|
417 |
|
|
418 |
media.on("setmuted", function(_muted) { |
|
419 |
popcorn.muted(_muted); |
|
420 |
media.muted = _muted; |
|
421 |
}); |
|
422 |
|
|
423 |
media.on("setplay", function() { |
|
424 |
popcorn.play(); |
|
425 |
}); |
|
426 |
|
|
427 |
media.on("setpause", function() { |
|
428 |
popcorn.pause(); |
|
429 |
}); |
|
430 |
|
|
431 |
// Binding Popcorn events to media |
|
432 |
|
|
433 |
function getVolume() { |
|
434 |
media.muted = popcorn.muted(); |
|
435 |
media.volume = popcorn.volume(); |
|
436 |
} |
|
437 |
|
|
438 |
popcorn.on("loadedmetadata", function() { |
|
439 |
getVolume(); |
|
440 |
media.trigger("loadedmetadata"); |
|
441 |
media.trigger("volumechange"); |
|
442 |
}) |
|
443 |
|
|
444 |
popcorn.on("timeupdate", function() { |
|
445 |
media.trigger("timeupdate", new IriSP.Model.Time(1000*popcorn.currentTime())); |
|
446 |
}); |
|
447 |
|
|
448 |
popcorn.on("volumechange", function() { |
|
449 |
getVolume(); |
|
450 |
media.trigger("volumechange"); |
|
451 |
}) |
|
452 |
|
|
453 |
popcorn.on("play", function() { |
|
454 |
media.trigger("play"); |
|
455 |
}); |
|
456 |
|
|
457 |
popcorn.on("pause", function() { |
|
458 |
media.trigger("pause"); |
|
459 |
}); |
|
460 |
|
|
461 |
popcorn.on("seeked", function() { |
|
462 |
media.trigger("seeked"); |
|
463 |
}); |
|
464 |
|
|
465 |
// Binding UI Events to Media |
|
466 |
|
|
467 |
media.on("play", function() { |
|
468 |
if (media === currentMedia) { |
|
469 |
onCurrentMediaPlay(); |
|
470 |
} |
|
471 |
}); |
|
472 |
|
|
473 |
media.on("pause", function() { |
|
474 |
if (media === currentMedia) { |
|
475 |
onCurrentMediaPause(); |
|
476 |
} |
|
477 |
}); |
|
478 |
|
|
479 |
media.on("timeupdate", function(_time) { |
|
480 |
if (media === currentMedia) { |
|
481 |
onCurrentMediaTimeupdate(_time); |
|
482 |
} |
|
| 25 | 483 |
}); |
484 |
|
|
485 |
media.on("volumechange", function() { |
|
486 |
if (media === currentMedia) { |
|
487 |
ctrlVolumeUpdater(); |
|
488 |
} |
|
| 23 | 489 |
}) |
| 18 | 490 |
|
| 13 | 491 |
} |
| 25 | 492 |
|
493 |
/* Segment Form interaction */ |
|
494 |
|
|
495 |
$("#segment-title").on("keyup change input paste", function() { |
|
496 |
if (currentMedia && currentMedia.currentSegment) { |
|
497 |
currentMedia.currentSegment.title = $(this).val(); |
|
498 |
} |
|
499 |
}); |
|
500 |
$("#segment-description").on("keyup change input paste", function() { |
|
501 |
if (currentMedia && currentMedia.currentSegment) { |
|
502 |
currentMedia.currentSegment.title = $(this).val(); |
|
503 |
} |
|
504 |
}); |
|
505 |
$("#segment-form").submit(function() { |
|
506 |
mashup.addSegment(currentMedia.currentSegment); |
|
507 |
currentMedia.currentSegment = undefined; |
|
508 |
}) |
|
509 |
|
|
| 22 | 510 |
/* Click on media items */ |
511 |
|
|
512 |
$(".col-left").on("click", ".item-video", function() { |
|
513 |
setMedia($(this).attr("data-media-id")); |
|
514 |
}); |
|
| 12 | 515 |
|
| 22 | 516 |
/* Click on Tabs */ |
517 |
|
|
518 |
function showSegmentation() { |
|
519 |
$(".col-middle").removeClass("empty-mode pvw-mode").addClass("segment-mode"); |
|
520 |
return false; |
|
521 |
} |
|
522 |
function showPreview() { |
|
523 |
$(".col-middle").removeClass("empty-mode segment-mode").addClass("pvw-mode"); |
|
524 |
return false; |
|
525 |
} |
|
526 |
|
|
527 |
$(".tab-pvw").click(showPreview); |
|
528 |
|
|
529 |
function disableMoveItemVideo() { |
|
530 |
$(".organize-segments .top, .organize-segments .bottom").removeClass("disable"); |
|
531 |
$(".organize-segments .item-video:last-child .bottom, .organize-segments .item-video:first-child .top").addClass("disable"); |
|
532 |
} |
|
|
24
1fbf7d835dc2
- update segment and bg video list
Anthony Ly <anthonyly.com@gmail.com>
parents:
23
diff
changeset
|
533 |
disableMoveItemVideo(); |
| 22 | 534 |
|
535 |
$(".organize-segments").sortable({ |
|
536 |
stop : function(){ |
|
537 |
disableMoveItemVideo(); |
|
538 |
} |
|
539 |
}); |
|
540 |
|
|
541 |
$(".organize-segments .top").click(function(e){ |
|
542 |
var currentItem = $(this).parents(".item-video"); |
|
543 |
currentItem.insertBefore(currentItem.prev()); |
|
544 |
disableMoveItemVideo(); |
|
545 |
}); |
|
546 |
|
|
547 |
$(".organize-segments .bottom").click(function(e){ |
|
548 |
var currentItem = $(this).parents(".item-video"); |
|
549 |
currentItem.insertAfter(currentItem.next()); |
|
550 |
disableMoveItemVideo(); |
|
551 |
}); |
|
552 |
|
|
| 25 | 553 |
/* Tangles */ |
554 |
var tangleMsPerPixel = 100, |
|
555 |
activeTangle, |
|
| 23 | 556 |
tangleStartX, |
| 25 | 557 |
tangleStartVal, |
558 |
tangleHasMoved; |
|
559 |
|
|
| 23 | 560 |
$(".time-tangle").mousedown(function(evt) { |
561 |
activeTangle = $(this); |
|
562 |
activeTangle.addClass("active"); |
|
563 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
564 |
tangleStartX = evt.pageX; |
|
| 25 | 565 |
tangleHasMoved = false; |
566 |
$(this).siblings(".time-tangle").addClass("deactivate"); |
|
| 23 | 567 |
return false; |
568 |
}); |
|
569 |
$(document) |
|
570 |
.mousemove(function(evt) { |
|
571 |
if (activeTangle) { |
|
| 25 | 572 |
tangleHasMoved = true; |
573 |
var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
| 23 | 574 |
activeTangle.trigger("valuechange", newval); |
575 |
return false; |
|
576 |
} |
|
577 |
}) |
|
578 |
.mouseup(function() { |
|
579 |
if (activeTangle) { |
|
| 25 | 580 |
$(".time-tangle").removeClass("active deactivate"); |
| 23 | 581 |
activeTangle = undefined; |
582 |
} |
|
| 25 | 583 |
}); |
584 |
|
|
585 |
$(".tangle-start") |
|
586 |
.mouseup(function(evt) { |
|
587 |
if (!tangleHasMoved && currentMedia && currentMedia.currentSegment) { |
|
588 |
currentMedia.setCurrentTime(currentMedia.currentSegment.begin); |
|
589 |
} |
|
| 23 | 590 |
}) |
| 25 | 591 |
.on("valuechange", function(evt, val) { |
592 |
if (currentMedia && currentMedia.currentSegment) { |
|
593 |
currentMedia.currentSegment.setBegin(val); |
|
594 |
} |
|
595 |
}); |
|
596 |
$(".tangle-end") |
|
597 |
.mouseup(function(evt) { |
|
598 |
if (!tangleHasMoved && currentMedia && currentMedia.currentSegment) { |
|
599 |
currentMedia.setCurrentTime(currentMedia.currentSegment.end); |
|
600 |
} |
|
601 |
}) |
|
602 |
.on("valuechange", function(evt, val) { |
|
603 |
if (currentMedia && currentMedia.currentSegment) { |
|
604 |
currentMedia.currentSegment.setEnd(val); |
|
605 |
} |
|
606 |
}); |
|
607 |
$(".tangle-duration").on("valuechange", function(evt, val) { |
|
608 |
if (currentMedia && currentMedia.currentSegment) { |
|
609 |
currentMedia.currentSegment.setDuration(val); |
|
610 |
} |
|
611 |
}); |
|
| 13 | 612 |
} |
613 |
||
614 |
$(function() { |
|
615 |
var hashcut = new IriSP.Hashcut(); |
|
| 12 | 616 |
}); |