2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-05-16 08:24:46 +00:00
|
|
|
|
|
|
|
/*@
|
|
|
|
Ox.VideoEditor <f:Ox.Element> VideoEditor Object
|
|
|
|
() -> <f> VideoEditor Object
|
|
|
|
(options) -> <f> VideoEditor Object
|
|
|
|
(options, self) -> <f> VideoEditor Object
|
|
|
|
options <o> Options object
|
|
|
|
self <o> shared private variable
|
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.VideoEditor = function(options, self) {
|
|
|
|
|
|
|
|
var self = self || {},
|
2011-04-29 12:40:51 +00:00
|
|
|
that = new Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
annotationsSize: 0,
|
|
|
|
cuts: [],
|
|
|
|
duration: 0,
|
|
|
|
find: '',
|
|
|
|
frameURL: function() {},
|
2011-05-18 16:00:29 +00:00
|
|
|
fps: 25,
|
2011-05-18 18:30:58 +00:00
|
|
|
getFrameURL: null,
|
2011-05-18 16:00:29 +00:00
|
|
|
getLargeTimelineImageURL: null,
|
|
|
|
getSmallTimelineImageURL: null,
|
|
|
|
'in': 0,
|
2011-04-22 22:03:10 +00:00
|
|
|
height: 0,
|
|
|
|
largeTimeline: true,
|
|
|
|
layers: [],
|
2011-05-18 16:00:29 +00:00
|
|
|
out: 0,
|
2011-04-22 22:03:10 +00:00
|
|
|
position: 0,
|
|
|
|
posterFrame: 0,
|
|
|
|
showAnnotations: false,
|
|
|
|
subtitles: [],
|
|
|
|
videoHeight: 0,
|
|
|
|
videoId: '',
|
|
|
|
videoWidth: 0,
|
|
|
|
videoSize: 'small',
|
|
|
|
videoURL: '',
|
|
|
|
width: 0
|
|
|
|
})
|
|
|
|
.options(options || {})
|
|
|
|
.mousedown(function() {
|
|
|
|
that.gainFocus();
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-05-18 16:00:29 +00:00
|
|
|
key_0: toggleMuted,
|
2011-04-22 22:03:10 +00:00
|
|
|
key_shift_0: function() {
|
|
|
|
movePositionBy(-self.options.position);
|
|
|
|
},
|
|
|
|
key_alt_left: function() {
|
|
|
|
},
|
|
|
|
key_alt_right: function() {
|
|
|
|
},
|
|
|
|
key_alt_shift_left: function() {
|
|
|
|
},
|
|
|
|
key_alt_shift_right: function() {
|
|
|
|
},
|
|
|
|
key_backslash: function() {
|
|
|
|
select('subtitle');
|
|
|
|
},
|
|
|
|
key_closebracket: function() {
|
|
|
|
movePositionTo('subtitle', 1);
|
|
|
|
},
|
|
|
|
key_comma: function() {
|
|
|
|
movePositionTo('cut', -1);
|
|
|
|
},
|
|
|
|
key_dot: function() {
|
|
|
|
movePositionTo('cut', 1);
|
|
|
|
},
|
|
|
|
key_down: function() {
|
|
|
|
movePositionBy(self.sizes.timeline[0].width);
|
|
|
|
},
|
|
|
|
key_i: function() {
|
|
|
|
setPoint('in');
|
|
|
|
},
|
|
|
|
key_left: function() {
|
2011-05-18 18:30:58 +00:00
|
|
|
movePositionBy(-0.04);
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
key_o: function() {
|
|
|
|
setPoint('out');
|
|
|
|
},
|
|
|
|
key_openbracket: function() {
|
|
|
|
movePositionTo('subtitle', -1);
|
|
|
|
},
|
|
|
|
key_p: playInToOut,
|
|
|
|
key_right: function() {
|
2011-05-18 18:30:58 +00:00
|
|
|
movePositionBy(0.04);
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
key_s: function() {
|
|
|
|
// toggleSize
|
|
|
|
},
|
|
|
|
key_shift_comma: function() {
|
|
|
|
movePositionTo('match', -1)
|
|
|
|
},
|
|
|
|
key_shift_dot: function() {
|
|
|
|
movePositionTo('match', 1)
|
|
|
|
},
|
|
|
|
key_shift_down: function() {
|
|
|
|
movePositionBy(self.options.duration);
|
|
|
|
},
|
|
|
|
key_shift_left: function() {
|
2011-05-18 18:30:58 +00:00
|
|
|
movePositionBy(1);
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
key_shift_i: function() {
|
|
|
|
goToPoint('in');
|
|
|
|
},
|
|
|
|
key_shift_o: function() {
|
|
|
|
goToPoint('out');
|
|
|
|
},
|
2011-05-19 07:06:42 +00:00
|
|
|
key_shift_p: function() {
|
|
|
|
// go to poster frame
|
|
|
|
},
|
2011-04-22 22:03:10 +00:00
|
|
|
key_shift_right: function() {
|
2011-05-18 18:30:58 +00:00
|
|
|
movePositionBy(1);
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
key_shift_up: function() {
|
2011-05-18 18:30:58 +00:00
|
|
|
movePositionBy(-self.options.position);
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
key_slash: function() {
|
|
|
|
select('cut');
|
|
|
|
},
|
2011-05-18 16:00:29 +00:00
|
|
|
key_space: togglePaused,
|
2011-04-22 22:03:10 +00:00
|
|
|
key_up: function() {
|
|
|
|
movePositionBy(-self.sizes.timeline[0].width);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$.extend(self, {
|
|
|
|
$player: [],
|
|
|
|
$timeline: [],
|
|
|
|
controlsHeight: 16,
|
|
|
|
margin: 8,
|
|
|
|
videoRatio: self.options.videoWidth / self.options.videoHeight
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$editor = new Ox.Element()
|
|
|
|
.addClass('OxVideoEditor')
|
|
|
|
.click(function() {
|
|
|
|
that.gainFocus()
|
|
|
|
});
|
|
|
|
|
|
|
|
self.sizes = getSizes();
|
|
|
|
|
|
|
|
['play', 'in', 'out'].forEach(function(type, i) {
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$player[i] = new Ox.VideoPlayer({
|
|
|
|
controlsBottom: type == 'play' ?
|
2011-05-18 18:30:58 +00:00
|
|
|
['play', 'playInToOut', 'volume', 'size', 'space', 'position'] :
|
2011-05-18 16:00:29 +00:00
|
|
|
['goto', 'set', 'space', 'position'],
|
2011-04-22 22:03:10 +00:00
|
|
|
duration: self.options.duration,
|
2011-05-18 16:00:29 +00:00
|
|
|
externalControls: true,
|
2011-04-22 22:03:10 +00:00
|
|
|
find: self.options.find,
|
|
|
|
height: self.sizes.player[i].height,
|
|
|
|
id: 'player' + Ox.toTitleCase(type),
|
2011-05-18 16:00:29 +00:00
|
|
|
'in': self.options['in'],
|
|
|
|
out: self.options.out,
|
|
|
|
paused: true,
|
|
|
|
position: type == 'play' ? self.options.position : self.options[type],
|
2011-04-22 22:03:10 +00:00
|
|
|
posterFrame: self.options.posterFrame,
|
2011-05-18 16:00:29 +00:00
|
|
|
showMarkers: true,
|
|
|
|
showMilliseconds: 2,
|
2011-04-22 22:03:10 +00:00
|
|
|
subtitles: self.options.subtitles,
|
|
|
|
type: type,
|
2011-05-18 18:30:58 +00:00
|
|
|
video: type == 'play' ? self.options.video : self.options.getFrameURL,
|
2011-04-22 22:03:10 +00:00
|
|
|
width: self.sizes.player[i].width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: self.sizes.player[i].left + 'px',
|
|
|
|
top: self.sizes.player[i].top + 'px'
|
|
|
|
})
|
|
|
|
.bindEvent(type == 'play' ? {
|
2011-05-18 16:00:29 +00:00
|
|
|
position: changePlayer,
|
|
|
|
size: toggleSize
|
2011-04-22 22:03:10 +00:00
|
|
|
} : {
|
2011-05-18 16:00:29 +00:00
|
|
|
gotopoint: function() {
|
2011-04-22 22:03:10 +00:00
|
|
|
goToPoint(type);
|
|
|
|
},
|
2011-05-18 16:00:29 +00:00
|
|
|
setpoint: function() {
|
2011-04-22 22:03:10 +00:00
|
|
|
setPoint(type);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$editor);
|
|
|
|
});
|
|
|
|
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$timeline[0] = new Ox.LargeVideoTimeline({
|
2011-04-22 22:03:10 +00:00
|
|
|
cuts: self.options.cuts,
|
|
|
|
duration: self.options.duration,
|
|
|
|
find: self.options.find,
|
2011-05-18 16:00:29 +00:00
|
|
|
getImageURL: self.options.getLargeTimelineImageURL,
|
2011-04-22 22:03:10 +00:00
|
|
|
id: 'timelineLarge',
|
2011-05-18 16:00:29 +00:00
|
|
|
'in': self.options['in'],
|
|
|
|
//matches: self.options.matches,
|
|
|
|
out: self.options.out,
|
2011-04-22 22:03:10 +00:00
|
|
|
position: self.options.position,
|
|
|
|
subtitles: self.options.subtitles,
|
2011-05-18 16:00:29 +00:00
|
|
|
type: 'editor',
|
2011-04-22 22:03:10 +00:00
|
|
|
width: self.sizes.timeline[0].width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: self.sizes.timeline[0].left + 'px',
|
|
|
|
top: self.sizes.timeline[0].top + 'px'
|
|
|
|
})
|
2011-05-18 16:00:29 +00:00
|
|
|
.bindEvent('position', changeTimelineLarge)
|
2011-04-22 22:03:10 +00:00
|
|
|
.appendTo(self.$editor);
|
|
|
|
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$timeline[1] = new Ox.BlockVideoTimeline({
|
2011-04-22 22:03:10 +00:00
|
|
|
cuts: self.options.cuts,
|
|
|
|
duration: self.options.duration,
|
|
|
|
find: self.options.find,
|
2011-05-18 16:00:29 +00:00
|
|
|
getImageURL: self.options.getSmallTimelineImageURL,
|
2011-04-22 22:03:10 +00:00
|
|
|
id: 'timelineSmall',
|
2011-05-18 16:00:29 +00:00
|
|
|
//matches: self.options.matches,
|
|
|
|
'in': self.options['in'],
|
|
|
|
out: self.options.out,
|
2011-04-22 22:03:10 +00:00
|
|
|
position: self.options.position,
|
|
|
|
subtitles: self.options.subtitles,
|
|
|
|
videoId: self.options.videoId,
|
|
|
|
width: self.sizes.timeline[1].width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: self.sizes.timeline[1].left + 'px',
|
2011-05-18 16:00:29 +00:00
|
|
|
top: self.sizes.timeline[1].top + 'px',
|
2011-04-22 22:03:10 +00:00
|
|
|
})
|
2011-05-18 16:00:29 +00:00
|
|
|
.bindEvent('position', changeTimelineSmall)
|
2011-04-22 22:03:10 +00:00
|
|
|
.appendTo(self.$editor);
|
|
|
|
|
|
|
|
self.$annotations = new Ox.Element()
|
|
|
|
.css({
|
|
|
|
overflowY: 'auto'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: resizeAnnotations,
|
|
|
|
toggle: toggleAnnotations
|
|
|
|
});
|
|
|
|
self.$annotationPanel = [];
|
|
|
|
|
|
|
|
self.options.layers.forEach(function(layer, i) {
|
|
|
|
self.$annotationPanel[i] = new Ox.AnnotationPanel(
|
|
|
|
$.extend({
|
|
|
|
width: self.options.annotationSize
|
|
|
|
}, layer)
|
|
|
|
)
|
|
|
|
.bindEvent({
|
|
|
|
add: function(event, data) {
|
|
|
|
data.layer = layer.id;
|
|
|
|
data['in'] = self.options.points[0];
|
|
|
|
data.out = self.options.points[1];
|
|
|
|
that.triggerEvent('addAnnotation', data);
|
|
|
|
},
|
|
|
|
'delete': function(event, data) {
|
|
|
|
data.layer = layer.id;
|
|
|
|
that.triggerEvent('removeAnnotations', data);
|
|
|
|
},
|
|
|
|
select: function(event, data) {
|
|
|
|
self.options.layers.forEach(function(l, j) { // fixme: l? j?
|
|
|
|
if(l.id != layer.id) {
|
|
|
|
self.$annotationPanel[j].deselectItems();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
selectAnnotation(event, data);
|
|
|
|
},
|
|
|
|
submit: updateAnnotation
|
|
|
|
});
|
|
|
|
self.$annotationPanel[i]
|
|
|
|
.appendTo(self.$annotations);
|
|
|
|
});
|
|
|
|
|
|
|
|
that.$element = new Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: self.$editor
|
|
|
|
},
|
|
|
|
{
|
|
|
|
collapsed: !self.options.showAnnotations,
|
|
|
|
collapsible: true,
|
|
|
|
element: self.$annotations,
|
|
|
|
resizable: true,
|
|
|
|
resize: [192, 256, 320, 384],
|
|
|
|
size: self.options.annotationsSize
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
});
|
|
|
|
|
2011-05-18 16:00:29 +00:00
|
|
|
function changePlayer(data) {
|
2011-04-22 22:03:10 +00:00
|
|
|
self.options.position = data.position;
|
|
|
|
self.$timeline[0].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
self.$timeline[1].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeTimelineLarge(event, data) {
|
|
|
|
self.options.position = data.position;
|
|
|
|
self.$player[0].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
self.$timeline[1].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeTimelineSmall(event, data) {
|
|
|
|
self.options.position = data.position;
|
|
|
|
self.$player[0].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
self.$timeline[0].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNextPosition(type, direction) {
|
|
|
|
var found = false,
|
|
|
|
position = 0,
|
|
|
|
positions;
|
|
|
|
if (type == 'cut') {
|
|
|
|
positions = self.options.cuts;
|
|
|
|
} else if (type == 'match') {
|
|
|
|
positions = $.map(self.options.matches, function(v, i) {
|
|
|
|
return self.options.subtitles[v]['in'];
|
|
|
|
});
|
|
|
|
} else if (type == 'subtitle') {
|
|
|
|
positions = $.map(self.options.subtitles, function(v, i) {
|
|
|
|
return v['in'];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
direction == -1 && positions.reverse();
|
|
|
|
Ox.forEach(positions, function(v) {
|
|
|
|
if (direction == 1 ? v > self.options.position : v < self.options.position) {
|
|
|
|
position = v;
|
|
|
|
found = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
direction == -1 && positions.reverse();
|
|
|
|
if (!found) {
|
|
|
|
position = positions[direction == 1 ? 0 : positions.length - 1];
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPoints(type) {
|
|
|
|
var found = false,
|
|
|
|
points,
|
|
|
|
positions = [];
|
|
|
|
if (type == 'cut') {
|
|
|
|
positions = self.options.cuts;
|
|
|
|
} else if (type == 'match') {
|
|
|
|
// ...
|
|
|
|
} else if (type == 'subtitle') {
|
|
|
|
self.options.subtitles.forEach(function(v, i) {
|
|
|
|
positions.push(v['in']);
|
|
|
|
positions.push(v.out);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
positions.indexOf(0) == -1 && positions.unshift(0);
|
|
|
|
positions.indexOf(self.options.duration) == -1 &&
|
|
|
|
positions.push(self.options.duration);
|
|
|
|
Ox.forEach(positions, function(v, i) {
|
|
|
|
if (v > self.options.position) {
|
|
|
|
points = [positions[i - 1], positions[i]];
|
|
|
|
found = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSizes(scrollbarIsVisible) {
|
|
|
|
//Ox.print('getSizes', scrollbarIsVisible)
|
|
|
|
var scrollbarWidth = Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
contentWidth = self.options.width -
|
|
|
|
(self.options.showAnnotations * self.options.annotationsSize) - 1 -
|
|
|
|
(scrollbarIsVisible ? scrollbarWidth : 0),
|
|
|
|
height,
|
|
|
|
lines,
|
|
|
|
size = {
|
|
|
|
player: [],
|
|
|
|
timeline: []
|
|
|
|
},
|
|
|
|
width, widths;
|
|
|
|
if (self.options.videoSize == 'small') {
|
|
|
|
width = 0;
|
|
|
|
widths = Ox.divideInt(contentWidth - 4 * self.margin, 3);
|
|
|
|
[1, 0, 2].forEach(function(v, i) {
|
|
|
|
size.player[v] = {
|
|
|
|
left: (i + 0.5) * self.margin + width,
|
|
|
|
top: self.margin / 2,
|
|
|
|
width: widths[i],
|
|
|
|
height: Math.round(widths[1] / self.videoRatio)
|
|
|
|
}
|
|
|
|
width += widths[i];
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
size.player[0] = {
|
|
|
|
left: self.margin / 2,
|
|
|
|
top: self.margin / 2,
|
|
|
|
width: Math.round((contentWidth - 3 * self.margin + (self.controlsHeight + self.margin) / 2 * self.videoRatio) * 2/3),
|
|
|
|
}
|
|
|
|
size.player[0].height = Math.round(size.player[0].width / self.videoRatio);
|
|
|
|
size.player[1] = {
|
|
|
|
left: size.player[0].left + size.player[0].width + self.margin,
|
|
|
|
top: size.player[0].top,
|
|
|
|
width: contentWidth - 3 * self.margin - size.player[0].width
|
|
|
|
}
|
|
|
|
size.player[1].height = Math.ceil(size.player[1].width / self.videoRatio)
|
|
|
|
size.player[2] = {
|
|
|
|
left: size.player[1].left,
|
|
|
|
top: size.player[0].top + size.player[1].height + self.controlsHeight + self.margin,
|
|
|
|
width: size.player[1].width,
|
|
|
|
height: size.player[0].height - size.player[1].height - self.controlsHeight - self.margin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size.timeline[0] = {
|
|
|
|
left: self.margin / 2,
|
|
|
|
top: size.player[0].height + self.controlsHeight + 1.5 * self.margin,
|
|
|
|
width: contentWidth - 2 * self.margin,
|
|
|
|
height: 64
|
|
|
|
}
|
|
|
|
size.timeline[1] = {
|
|
|
|
left: size.timeline[0].left,
|
|
|
|
top: size.timeline[0].top + size.timeline[0].height + self.margin,
|
|
|
|
width: size.timeline[0].width
|
|
|
|
}
|
|
|
|
lines = Math.ceil(self.options.duration / size.timeline[1].width);
|
|
|
|
height = getHeight();
|
|
|
|
self.$editor.css({
|
|
|
|
overflowY: (scrollbarIsVisible && height <= self.options.height) ? 'scroll' : 'auto'
|
|
|
|
});
|
2011-05-19 07:06:42 +00:00
|
|
|
//Ox.print('getSizes', scrollbarIsVisible, height, self.options.height, size)
|
2011-04-22 22:03:10 +00:00
|
|
|
return (!scrollbarIsVisible && height > self.options.height) ? getSizes(true) : size;
|
|
|
|
function getHeight() {
|
|
|
|
return size.player[0].height + self.controlsHeight +
|
|
|
|
size.timeline[0].height + lines * 16 +
|
|
|
|
(lines + 3) * self.margin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function goToPoint(point) {
|
2011-05-18 16:00:29 +00:00
|
|
|
self.options.position = self.options[point];
|
2011-04-22 22:03:10 +00:00
|
|
|
setPosition();
|
2011-05-18 16:00:29 +00:00
|
|
|
that.triggerEvent('position', {
|
2011-04-22 22:03:10 +00:00
|
|
|
position: self.options.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function movePositionBy(sec) {
|
|
|
|
self.options.position = Ox.limit(self.options.position + sec, 0, self.options.duration);
|
|
|
|
setPosition();
|
2011-05-18 16:00:29 +00:00
|
|
|
that.triggerEvent('position', {
|
2011-04-22 22:03:10 +00:00
|
|
|
position: self.options.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function movePositionTo(type, direction) {
|
|
|
|
self.options.position = getNextPosition(type, direction);
|
|
|
|
setPosition();
|
2011-05-18 16:00:29 +00:00
|
|
|
that.triggerEvent('position', {
|
2011-04-22 22:03:10 +00:00
|
|
|
position: self.options.position
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function playInToOut() {
|
|
|
|
self.$player[0].playInToOut();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeAnnotations(event, data) {
|
|
|
|
self.options.annotationsSize = data;
|
|
|
|
setSizes();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeEditor(event, data) {
|
|
|
|
var width = data - 2 * margin + 100;
|
|
|
|
resizeVideoPlayers(width);
|
|
|
|
$timelineLarge.options({
|
|
|
|
width: width
|
|
|
|
});
|
|
|
|
$timelineSmall.options({
|
|
|
|
width: width
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizePlayers() {
|
|
|
|
self.$player.forEach(function(v, i) {
|
|
|
|
v.options({
|
|
|
|
width: size[i].width,
|
|
|
|
height: size[i].height
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: size[i].left + 'px',
|
|
|
|
top: size[i].top + 'px',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectAnnotation(event, data) {
|
|
|
|
self.options.position = data['in']
|
|
|
|
self.options.points = [data['in'], data.out];
|
|
|
|
setPosition();
|
|
|
|
setPoints();
|
|
|
|
}
|
|
|
|
function updateAnnotation(event, data) {
|
|
|
|
data['in'] = self.options.points[0];
|
|
|
|
data.out = self.options.points[1];
|
|
|
|
that.triggerEvent('updateAnnotation', data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function select(type) {
|
|
|
|
self.options.points = getPoints(type);
|
|
|
|
setPoints();
|
|
|
|
}
|
|
|
|
|
|
|
|
function setPoint(point) {
|
2011-05-18 18:30:58 +00:00
|
|
|
var otherPoint = point == 'in' ? 'out' : 'in';
|
2011-05-18 16:00:29 +00:00
|
|
|
self.options[point] = self.options.position;
|
2011-05-18 18:30:58 +00:00
|
|
|
self.$player.forEach(function($player) {
|
|
|
|
$player.options(point, self.options[point]);
|
|
|
|
});
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$player[point == 'in' ? 1 : 2].options({
|
|
|
|
position: self.options[point]
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$timeline.forEach(function($timeline) {
|
|
|
|
$timeline.options(point, self.options[point]);
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-05-18 16:00:29 +00:00
|
|
|
if (self.options['in'] > self.options.out) {
|
|
|
|
setPoint(point == 'in' ? 'out' : 'in');
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setPosition() {
|
|
|
|
self.$player[0].options({
|
|
|
|
position: self.options.position
|
|
|
|
});
|
|
|
|
self.$timeline.forEach(function(v) {
|
|
|
|
v.options({
|
|
|
|
position: self.options.position
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSizes() {
|
|
|
|
self.sizes = getSizes();
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$player.forEach(function($player, i) {
|
|
|
|
$player.options({
|
2011-04-22 22:03:10 +00:00
|
|
|
height: self.sizes.player[i].height,
|
|
|
|
width: self.sizes.player[i].width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: self.sizes.player[i].left + 'px',
|
|
|
|
top: self.sizes.player[i].top + 'px'
|
|
|
|
});
|
|
|
|
});
|
2011-05-18 16:00:29 +00:00
|
|
|
self.$timeline.forEach(function($timeline, i) {
|
|
|
|
$timeline.options({
|
2011-04-22 22:03:10 +00:00
|
|
|
width: self.sizes.timeline[i].width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: self.sizes.timeline[i].left + 'px',
|
|
|
|
top: self.sizes.timeline[i].top + 'px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleAnnotations(event, data) {
|
|
|
|
self.options.showAnnotations = !data.collapsed;
|
|
|
|
setSizes();
|
|
|
|
}
|
|
|
|
|
2011-05-18 16:00:29 +00:00
|
|
|
function toggleMuted() {
|
|
|
|
self.$player[0].toggleMuted();
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 16:00:29 +00:00
|
|
|
function togglePaused() {
|
|
|
|
self.$player[0].togglePaused();
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleSize(event, data) {
|
|
|
|
self.options.videoSize = data.size
|
|
|
|
setSizes();
|
|
|
|
that.triggerEvent('togglesize', {
|
|
|
|
size: self.options.videoSize
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-04-29 12:40:51 +00:00
|
|
|
self.setOption = function(key, value) {
|
2011-04-22 22:03:10 +00:00
|
|
|
if (key == 'width' || key == 'height') {
|
2011-05-18 16:00:29 +00:00
|
|
|
Ox.print('XXXX setSizes', key, value, self.options.width, self.options.height)
|
2011-04-22 22:03:10 +00:00
|
|
|
setSizes();
|
|
|
|
} else if (key == 'position') {
|
|
|
|
self.$player[0].position(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
that.addAnnotation = function(layer, item) {
|
|
|
|
var i = Ox.getPositionById(self.options.layers, layer);
|
|
|
|
self.$annotationPanel[i].addItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
that.removeAnnotations = function(layer, ids) {
|
|
|
|
var i = Ox.getPositionById(self.options.layers, layer);
|
|
|
|
self.$annotationPanel[i].removeItems(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|