enable timeline types

This commit is contained in:
rlx 2012-06-15 13:20:07 +00:00
parent fbeb434e27
commit 856ea3b1d3
7 changed files with 134 additions and 94 deletions

View file

@ -36,6 +36,7 @@ Ox.BlockVideoTimeline = function(options, self) {
results: setResults, results: setResults,
subtitles: setSubtitles, subtitles: setSubtitles,
state: setState, state: setState,
type: setType,
width: setWidth width: setWidth
}) })
.addClass('OxBlockVideoTimeline') .addClass('OxBlockVideoTimeline')
@ -69,19 +70,7 @@ Ox.BlockVideoTimeline = function(options, self) {
setCSS(); setCSS();
self.$image = Ox.SmallVideoTimelineImage({ self.$image = getImage();
duration: self.options.duration,
editing: self.options.editing,
imageURL: self.options.getImageURL,
'in': self.options['in'],
mode: 'editor',
out: self.options.out,
results: self.options.results,
state: self.options.state,
subtitles: self.options.subtitles,
type: self.options.type,
width: Math.round(self.options.duration)
});
Ox.loop(self.lines, function(i) { Ox.loop(self.lines, function(i) {
addLine(i); addLine(i);
@ -155,6 +144,22 @@ Ox.BlockVideoTimeline = function(options, self) {
} }
} }
function getImage() {
return Ox.SmallVideoTimelineImage({
duration: self.options.duration,
editing: self.options.editing,
imageURL: self.options.getImageURL,
'in': self.options['in'],
mode: 'editor',
out: self.options.out,
results: self.options.results,
state: self.options.state,
subtitles: self.options.subtitles,
type: self.options.type,
width: Math.round(self.options.duration)
});
}
function getLines() { function getLines() {
return Math.ceil(self.options.duration / self.options.width); return Math.ceil(self.options.duration / self.options.width);
} }
@ -270,6 +275,19 @@ Ox.BlockVideoTimeline = function(options, self) {
updateTimelines(); updateTimelines();
} }
function setType() {
self.$image = getImage();
self.$images.forEach(function($image, i) {
self.$images[i].replaceWith(
self.$images[i] = self.$image.clone()
.css({
position: 'absolute',
marginLeft: -i * self.options.width + 'px'
})
);
});
}
function setWidth() { function setWidth() {
self.lines = getLines(); self.lines = getLines();
setCSS(); setCSS();
@ -303,8 +321,7 @@ Ox.BlockVideoTimeline = function(options, self) {
function updateTimelines() { function updateTimelines() {
self.$lines.forEach(function($line, i) { self.$lines.forEach(function($line, i) {
$($line.children()[0]).replaceWith( $($line.children()[0]).replaceWith(
self.$images[i] = self.$image.clone() self.$images[i] = self.$image.clone().css({
.css({
position: 'absolute', position: 'absolute',
marginLeft: (-i * self.options.width) + 'px' marginLeft: (-i * self.options.width) + 'px'
}) })

View file

@ -35,6 +35,7 @@ Ox.LargeVideoTimeline = function(options, self) {
}, },
position: setPosition, position: setPosition,
subtitles: setSubtitles, subtitles: setSubtitles,
type: setType,
width: setWidth width: setWidth
}) })
.addClass('OxLargeVideoTimeline') .addClass('OxLargeVideoTimeline')
@ -46,56 +47,42 @@ Ox.LargeVideoTimeline = function(options, self) {
drag: drag drag: drag
}); });
Ox.extend(self, { self.$cuts = [];
$cuts: [], self.$pointMarker = {};
$pointMarker: {}, self.$tiles = {};
$tiles: {}, self.$tooltip = Ox.Tooltip({animate: false});
$tooltip: Ox.Tooltip({ self.center = Math.floor(self.options.width / 2);
animate: false self.fps = 25;
}), self.height = 64;
center: Math.floor(self.options.width / 2), self.tileWidth = 150;
element: that.$element[0],
fps: 25,
height: 64,
tileWidth: 1500
});
self.tiles = self.options.duration * self.fps / self.tileWidth; self.tiles = self.options.duration * self.fps / self.tileWidth;
self.$timeline = $('<div>') self.$timeline = $('<div>')
.css({ .css({left: self.center + 'px'})
left: self.center + 'px' .appendTo(that)
})
.appendTo(that.$element)
setSubtitles(); setSubtitles();
self.options.cuts.forEach(function(v, i) { self.options.cuts.forEach(function(v, i) {
self.$cuts[i] = $('<img>') self.$cuts[i] = $('<img>')
.addClass('OxCut') .addClass('OxCut')
.attr({ .attr({src: Ox.UI.getImageURL('markerCut')})
src: Ox.UI.getImageURL('markerCut') .css({left: (v * self.fps) + 'px'})
})
.css({
left: (v * self.fps) + 'px'
})
.appendTo(self.$timeline) .appendTo(self.$timeline)
}); });
self.$markerPosition = $('<img>') self.$markerPosition = $('<img>')
.addClass('OxMarkerPosition') .addClass('OxMarkerPosition')
.attr({ .attr({src: Ox.UI.getImageURL('markerPosition')})
src: Ox.UI.getImageURL('markerPosition') .appendTo(that);
})
.appendTo(that.$element);
setMarker(); setMarker();
['in', 'out'].forEach(function(point) { ['in', 'out'].forEach(function(point) {
var titlecase = Ox.toTitleCase(point); var titlecase = Ox.toTitleCase(point);
self.$pointMarker[point] = $('<img>') self.$pointMarker[point] = $('<img>')
.addClass('OxMarkerPoint' + titlecase) .addClass('OxMarkerPoint' + titlecase)
.attr({ .attr({src: Ox.UI.getImageURL('marker' + titlecase)})
src: Ox.UI.getImageURL('marker' + titlecase)
})
.appendTo(self.$timeline); .appendTo(self.$timeline);
setPointMarker(point); setPointMarker(point);
}); });
@ -126,7 +113,9 @@ Ox.LargeVideoTimeline = function(options, self) {
} }
function getPosition(e) { function getPosition(e) {
return self.options.position + (e.clientX - that.offset().left - self.center - 1) / self.fps; return self.options.position + (
e.clientX - that.offset().left - self.center - 1
) / self.fps;
} }
function mouseleave(e) { function mouseleave(e) {
@ -142,9 +131,7 @@ Ox.LargeVideoTimeline = function(options, self) {
} }
function setMarker() { function setMarker() {
self.$markerPosition.css({ self.$markerPosition.css({left: self.center + 'px'});
left: self.center + 'px'
});
} }
function setPointMarker(point) { function setPointMarker(point) {
@ -198,6 +185,12 @@ Ox.LargeVideoTimeline = function(options, self) {
}); });
} }
function setType() {
Ox.forEach(self.$tiles, function($tile, i) {
$tile.attr({src: self.options.getImageURL(self.options.type, i)});
});
}
function setWidth() { function setWidth() {
self.center = Math.floor(self.options.width / 2); self.center = Math.floor(self.options.width / 2);
that.css({ that.css({
@ -210,9 +203,7 @@ Ox.LargeVideoTimeline = function(options, self) {
} }
function triggerPositionEvent() { function triggerPositionEvent() {
that.triggerEvent('position', { that.triggerEvent('position', {position: self.options.position});
position: self.options.position
});
} }
function updateTooltip() { function updateTooltip() {

View file

@ -97,7 +97,7 @@ Ox.SmallVideoTimelineImage = function(options, self) {
width: self.options.width + 'px', width: self.options.width + 'px',
height: '16px' height: '16px'
}) })
.appendTo(that.$element); .appendTo(that);
} else { } else {
Ox.loop(self.images, function(i) { Ox.loop(self.images, function(i) {
$('<img>') $('<img>')
@ -111,7 +111,7 @@ Ox.SmallVideoTimelineImage = function(options, self) {
width: (i == self.images - 1 ? self.imageWidth % 3600 : 3600) + 'px', width: (i == self.images - 1 ? self.imageWidth % 3600 : 3600) + 'px',
height: '16px' height: '16px'
}) })
.appendTo(that.$element); .appendTo(that);
}); });
} }
@ -239,10 +239,6 @@ Ox.SmallVideoTimelineImage = function(options, self) {
return canvas.toDataURL(); return canvas.toDataURL();
} }
function getPosition() {
}
return that; return that;
}; };

View file

@ -89,6 +89,10 @@ Ox.VideoEditor = function(options, self) {
showAnnotations: function() { showAnnotations: function() {
that.$element.toggle(1); that.$element.toggle(1);
}, },
timeline: function() {
self.$menuButton.checkItem(self.options.timeline);
updateTimelines();
},
width: setSizes width: setSizes
}) })
.bindEvent({ .bindEvent({
@ -495,8 +499,7 @@ Ox.VideoEditor = function(options, self) {
self.options.timelines, self.options.timelines,
function(timeline) { function(timeline) {
return Ox.extend({ return Ox.extend({
checked: timeline.id == self.options.timeline, checked: timeline.id == self.options.timeline
disabled: true
}, timeline); }, timeline);
} }
)}, )},
@ -564,7 +567,11 @@ Ox.VideoEditor = function(options, self) {
} else if (id == 'subtitles') { } else if (id == 'subtitles') {
toggleSubtitles(); toggleSubtitles();
} else if (id == 'timeline') { } else if (id == 'timeline') {
// data.checked[0].id self.options.timeline = data.checked[0].id;
updateTimelines();
that.triggerEvent('timeline', {
timeline: self.options.timeline
});
} }
}, },
hide: function() { hide: function() {
@ -1367,6 +1374,11 @@ Ox.VideoEditor = function(options, self) {
}); });
} }
function updateTimelines() {
self.$timeline[0].options({type: self.options.timeline});
self.$timeline[1].options({type: self.options.timeline});
}
function updateWords(action) { function updateWords(action) {
// action can be 'add' or 'remove' // action can be 'add' or 'remove'
var words = []; var words = [];

View file

@ -87,6 +87,9 @@ Ox.VideoPanel = function(options, self) {
showTimeline: function() { showTimeline: function() {
self.$videoPanel.toggle(1); self.$videoPanel.toggle(1);
}, },
timeline: function() {
self.$timeline.options({type: self.options.timeline});
},
width: function() { width: function() {
self.$video.options({width: getPlayerWidth()}); self.$video.options({width: getPlayerWidth()});
self.$timeline.options({width: getTimelineWidth()}); self.$timeline.options({width: getTimelineWidth()});

View file

@ -53,9 +53,7 @@ Ox.VideoTimelinePanel = function(options, self) {
self.$player.options({height: self.options.height}); self.$player.options({height: self.options.height});
}, },
paused: function() { paused: function() {
self.$player.options({ self.$player.options({paused: self.options.paused});
paused: self.options.paused
});
}, },
position: function() { position: function() {
setPosition(self.options.position); setPosition(self.options.position);
@ -63,6 +61,9 @@ Ox.VideoTimelinePanel = function(options, self) {
showAnnotations: function() { showAnnotations: function() {
that.$element.toggle(1); that.$element.toggle(1);
}, },
timeline: function() {
self.$player.options({timeline: self.options.timeline});
},
width: function() { width: function() {
self.$player.options({width: getPlayerWidth()}); self.$player.options({width: getPlayerWidth()});
} }

View file

@ -45,6 +45,10 @@ Ox.VideoTimelinePlayer = function(options, self) {
togglePaused(); togglePaused();
}, },
position: setPosition, position: setPosition,
timeline: function() {
self.$menuButton.checkItem(self.options.timeline);
updateTimeline();
},
width: setWidth width: setWidth
}); });
@ -73,8 +77,7 @@ Ox.VideoTimelinePlayer = function(options, self) {
self.options.timelines, self.options.timelines,
function(timeline) { function(timeline) {
return Ox.extend({ return Ox.extend({
checked: timeline.id == self.options.timeline, checked: timeline.id == self.options.timeline
disabled: true
}, timeline); }, timeline);
} }
)}, )},
@ -95,7 +98,11 @@ Ox.VideoTimelinePlayer = function(options, self) {
change: function(data) { change: function(data) {
var id = data.id; var id = data.id;
if (id == 'timeline') { if (id == 'timeline') {
// data.checked[0].id self.options.timeline = data.checked[0].id;
updateTimeline();
that.triggerEvent('timeline', {
timeline: self.options.timeline
});
} else if (id == 'followPlayer') { } else if (id == 'followPlayer') {
self.options.followPlayer = data.checked; self.options.followPlayer = data.checked;
if (!self.options.paused && self.options.followPlayer) { if (!self.options.paused && self.options.followPlayer) {
@ -268,7 +275,6 @@ Ox.VideoTimelinePlayer = function(options, self) {
self.$lines = []; self.$lines = [];
self.$timelines = []; self.$timelines = [];
self.$interfaces = [];
self.$timeline = renderTimeline(); self.$timeline = renderTimeline();
//setSubtitles(); //setSubtitles();
@ -397,12 +403,12 @@ Ox.VideoTimelinePlayer = function(options, self) {
}) })
.appendTo(self.$timelinePlayer); .appendTo(self.$timelinePlayer);
self.$timelines[i] = [ self.$timelines[i] = [
self.$timeline.clone() self.$timeline.clone(true)
.css({ .css({
width: self.frame + self.videoWidth + 'px', width: self.frame + self.videoWidth + 'px',
marginLeft: -i * self.contentWidth + 'px' marginLeft: -i * self.contentWidth + 'px'
}), }),
self.$timeline.clone() self.$timeline.clone(true)
.css({ .css({
marginLeft: -i * self.contentWidth + self.videoWidth - 1 + 'px' marginLeft: -i * self.contentWidth + self.videoWidth - 1 + 'px'
}) })
@ -591,6 +597,7 @@ Ox.VideoTimelinePlayer = function(options, self) {
left: i * self.tileWidth + 'px', left: i * self.tileWidth + 'px',
top: self.margin / 2 + 'px' top: self.margin / 2 + 'px'
}) })
.data({index: i})
.appendTo($timeline); .appendTo($timeline);
}); });
$('<div>') $('<div>')
@ -601,10 +608,8 @@ Ox.VideoTimelinePlayer = function(options, self) {
top: self.margin / 2 + 'px', top: self.margin / 2 + 'px',
width: self.frames + 'px', width: self.frames + 'px',
height: self.tileHeight + 'px' height: self.tileHeight + 'px'
//background: 'rgba(255, 0, 0, 0.5)'
}) })
.appendTo($timeline); .appendTo($timeline);
return $timeline; return $timeline;
} }
@ -715,6 +720,10 @@ Ox.VideoTimelinePlayer = function(options, self) {
}); });
} }
function setTimeline() {
self.$timelinePlayer.empty();
}
function setVolume() { function setVolume() {
self.$video.options({volume: self.options.volume}); self.$video.options({volume: self.options.volume});
that.triggerEvent('volume', { that.triggerEvent('volume', {
@ -807,6 +816,17 @@ Ox.VideoTimelinePlayer = function(options, self) {
} }
} }
function updateTimeline() {
self.$timelinePlayer.find('img').each(function() {
var $this = $(this);
$this.attr({
src: self.options.getLargeTimelineURL(
self.options.timeline, $this.data('index')
)
});
});
}
/*@ /*@
togglePaused <f> toggle paused togglePaused <f> toggle paused
() -> <o> toggle paused () -> <o> toggle paused