2012-04-17 07:52:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.VideoTimelinePanel <f> Video timeline panel
|
2012-07-04 11:29:18 +00:00
|
|
|
options <o> Options
|
|
|
|
self <o> Shared private variable
|
2012-05-31 10:32:54 +00:00
|
|
|
([options[, self]]) -> <o:Ox.SplitPanel> Video timeline panel
|
2012-06-17 22:38:26 +00:00
|
|
|
annoationssize <!> annoationssize
|
|
|
|
annotationsrange <!> annotationsrange
|
|
|
|
annotationssort <!> annotationssort
|
2014-07-24 17:47:00 +00:00
|
|
|
audioTrack <s|''> Two-letter ISO 639-1 language code or track name
|
2012-06-17 22:38:26 +00:00
|
|
|
censored <!> censored
|
|
|
|
follow <!> follow
|
|
|
|
info <!> info
|
|
|
|
muted <!> muted
|
|
|
|
paused <!> paused
|
|
|
|
position <!> position
|
|
|
|
resizecalendar <!> resizecalendar
|
|
|
|
resizemap <!> resizemap
|
|
|
|
select <!> select
|
|
|
|
timeline <!> timeline
|
|
|
|
toggleannotations <!> toggleannotations
|
|
|
|
togglecalendar <!> togglecalendar
|
|
|
|
togglelayer <!> togglelayer
|
|
|
|
togglemap <!> togglemap
|
|
|
|
volume <!> volume
|
2012-04-17 07:52:37 +00:00
|
|
|
@*/
|
|
|
|
|
|
|
|
Ox.VideoTimelinePanel = function(options, self) {
|
|
|
|
|
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
|
|
|
.defaults({
|
|
|
|
annotationsCalendarSize: 256,
|
|
|
|
annotationsMapSize: 256,
|
|
|
|
annotationsRange: 'all',
|
|
|
|
annotationsSize: 256,
|
|
|
|
annotationsSort: 'position',
|
2012-09-17 08:36:21 +00:00
|
|
|
annotationsTooltip: 'annotations',
|
2014-07-24 17:47:00 +00:00
|
|
|
audioTrack: '',
|
2012-04-17 07:52:37 +00:00
|
|
|
censored: [],
|
2012-04-22 09:57:17 +00:00
|
|
|
censoredIcon: '',
|
|
|
|
censoredTooltip: '',
|
2012-04-17 07:52:37 +00:00
|
|
|
clickLink: null,
|
|
|
|
cuts: [],
|
|
|
|
duration: 0,
|
2012-04-17 12:01:24 +00:00
|
|
|
followPlayer: false,
|
|
|
|
getFrameURL: null,
|
2012-04-18 07:43:32 +00:00
|
|
|
getLargeTimelineURL: null,
|
2012-04-17 07:52:37 +00:00
|
|
|
height: 0,
|
2014-01-19 06:28:59 +00:00
|
|
|
'in': 0,
|
|
|
|
itemName: {singular: 'video', plural: 'videos'},
|
2012-04-17 07:52:37 +00:00
|
|
|
layers: [],
|
|
|
|
loop: false, // fixme: used?
|
|
|
|
muted: false,
|
|
|
|
out: 0,
|
2012-05-26 19:01:05 +00:00
|
|
|
paused: true,
|
2016-03-29 12:26:04 +00:00
|
|
|
playbackRate: 1,
|
2012-04-17 07:52:37 +00:00
|
|
|
position: 0,
|
|
|
|
resolution: 0,
|
|
|
|
selected: '',
|
|
|
|
showAnnotations: false,
|
|
|
|
showAnnotationsCalendar: false,
|
|
|
|
showAnnotationsMap: false,
|
|
|
|
showLayers: {},
|
|
|
|
showUsers: false,
|
2012-04-18 07:43:32 +00:00
|
|
|
smallTimelineURL: '',
|
2012-04-17 07:52:37 +00:00
|
|
|
subtitles: [],
|
2012-04-17 12:01:24 +00:00
|
|
|
timeline: '',
|
|
|
|
timelines: [],
|
2012-04-17 07:52:37 +00:00
|
|
|
video: '',
|
|
|
|
volume: 1,
|
|
|
|
width: 0
|
|
|
|
})
|
|
|
|
.options(options || {})
|
2012-05-28 19:35:41 +00:00
|
|
|
.update({
|
|
|
|
height: function() {
|
|
|
|
self.$player.options({height: self.options.height});
|
|
|
|
},
|
|
|
|
paused: function() {
|
2012-06-15 13:20:07 +00:00
|
|
|
self.$player.options({paused: self.options.paused});
|
2012-05-28 19:35:41 +00:00
|
|
|
},
|
2016-03-29 12:26:04 +00:00
|
|
|
playbackRate: function() {
|
|
|
|
self.$player.options({playbackRate: self.options.playbackRate});
|
|
|
|
},
|
2012-05-28 19:35:41 +00:00
|
|
|
position: function() {
|
|
|
|
setPosition(self.options.position);
|
|
|
|
},
|
|
|
|
showAnnotations: function() {
|
2014-09-24 18:19:25 +00:00
|
|
|
self.$panel.toggleElement(1);
|
2012-05-28 19:35:41 +00:00
|
|
|
},
|
2012-06-15 13:20:07 +00:00
|
|
|
timeline: function() {
|
|
|
|
self.$player.options({timeline: self.options.timeline});
|
|
|
|
},
|
2012-05-28 19:35:41 +00:00
|
|
|
width: function() {
|
|
|
|
self.$player.options({width: getPlayerWidth()});
|
|
|
|
}
|
|
|
|
})
|
2012-04-17 07:52:37 +00:00
|
|
|
.css({
|
|
|
|
height: self.options.height + 'px',
|
|
|
|
width: self.options.width + 'px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: resizeElement,
|
|
|
|
key_0: toggleMuted,
|
|
|
|
key_equal: function() {
|
|
|
|
self.$video.changeVolume(0.1);
|
|
|
|
},
|
|
|
|
key_minus: function() {
|
|
|
|
self.$video.changeVolume(-0.1);
|
|
|
|
},
|
|
|
|
key_space: togglePaused
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$player = Ox.VideoTimelinePlayer({
|
2014-07-24 17:47:00 +00:00
|
|
|
audioTrack: self.options.audioTrack,
|
2012-04-17 07:52:37 +00:00
|
|
|
censored: self.options.censored,
|
2012-04-22 09:57:17 +00:00
|
|
|
censoredIcon: self.options.censoredIcon,
|
|
|
|
censoredTooltip: self.options.censoredTooltip,
|
2012-04-17 07:52:37 +00:00
|
|
|
cuts: self.options.cuts,
|
2012-04-17 12:01:24 +00:00
|
|
|
duration: self.options.duration,
|
|
|
|
followPlayer: self.options.followPlayer,
|
|
|
|
getFrameURL: self.options.getFrameURL,
|
2012-04-18 07:43:32 +00:00
|
|
|
getLargeTimelineURL: self.options.getLargeTimelineURL,
|
2012-04-17 12:01:24 +00:00
|
|
|
height: self.options.height,
|
2012-04-17 07:52:37 +00:00
|
|
|
muted: self.options.muted,
|
2012-05-26 19:01:05 +00:00
|
|
|
paused: self.options.paused,
|
2016-03-29 12:26:04 +00:00
|
|
|
playbackRate: self.options.playbackRate,
|
2012-04-17 07:52:37 +00:00
|
|
|
position: self.options.position,
|
|
|
|
resolution: self.options.resolution,
|
2012-04-18 07:43:32 +00:00
|
|
|
smallTimelineURL: self.options.smallTimelineURL,
|
2012-04-17 12:01:24 +00:00
|
|
|
subtitles: self.options.subtitles,
|
|
|
|
timeline: self.options.timeline,
|
|
|
|
timelines: self.options.timelines,
|
|
|
|
video: self.options.video,
|
|
|
|
videoRatio: self.options.videoRatio,
|
|
|
|
volume: self.options.volume,
|
|
|
|
width: getPlayerWidth()
|
2012-04-17 07:52:37 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
2012-04-22 09:57:17 +00:00
|
|
|
censored: function() {
|
|
|
|
that.triggerEvent('censored');
|
|
|
|
},
|
2012-04-17 13:42:46 +00:00
|
|
|
follow: function(data) {
|
|
|
|
that.triggerEvent('follow', data);
|
|
|
|
},
|
2012-04-17 07:52:37 +00:00
|
|
|
muted: function(data) {
|
|
|
|
that.triggerEvent('muted', data);
|
|
|
|
},
|
|
|
|
paused: function(data) {
|
2013-08-07 09:59:47 +00:00
|
|
|
self.options.paused = data.paused;
|
2012-04-17 07:52:37 +00:00
|
|
|
that.triggerEvent('paused', data);
|
|
|
|
},
|
|
|
|
playing: function(data) {
|
|
|
|
setPosition(data.position, true);
|
|
|
|
},
|
|
|
|
position: function(data) {
|
|
|
|
setPosition(data.position);
|
|
|
|
},
|
2012-04-18 07:43:32 +00:00
|
|
|
timeline: function(data) {
|
|
|
|
that.triggerEvent('timeline', data);
|
|
|
|
},
|
2012-04-17 07:52:37 +00:00
|
|
|
volume: function(data) {
|
|
|
|
that.triggerEvent('volume', data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-17 12:01:24 +00:00
|
|
|
self.$annotationPanel = Ox.AnnotationPanel({
|
|
|
|
calendarSize: self.options.annotationsCalendarSize,
|
|
|
|
clickLink: self.options.clickLink,
|
|
|
|
editable: false,
|
|
|
|
highlight: self.options.find,
|
|
|
|
'in': self.options['in'],
|
2014-01-19 06:28:59 +00:00
|
|
|
itemName: self.options.itemName,
|
2012-04-17 12:01:24 +00:00
|
|
|
layers: self.options.layers,
|
|
|
|
mapSize: self.options.annotationsMapSize,
|
|
|
|
out: self.options.out,
|
|
|
|
position: self.options.position,
|
|
|
|
range: self.options.annotationsRange,
|
|
|
|
selected: self.options.selected,
|
|
|
|
showCalendar: self.options.showAnnotationsCalendar,
|
|
|
|
showLayers: Ox.clone(self.options.showLayers),
|
|
|
|
showMap: self.options.showAnnotationsMap,
|
|
|
|
showUsers: self.options.showUsers,
|
|
|
|
sort: self.options.annotationsSort,
|
|
|
|
width: self.options.annotationsSize
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
annotationsrange: function(data) {
|
|
|
|
self.options.annotationsRange = data.range;
|
|
|
|
that.triggerEvent('annotationsrange', data);
|
|
|
|
},
|
|
|
|
annotationssort: function(data) {
|
|
|
|
self.options.annotationsSort = data.sort;
|
|
|
|
that.triggerEvent('annotationssort', data);
|
|
|
|
},
|
2012-04-22 11:13:06 +00:00
|
|
|
info: function(data) {
|
|
|
|
that.triggerEvent('info', data);
|
|
|
|
},
|
2012-04-17 12:01:24 +00:00
|
|
|
open: function() {
|
|
|
|
setPosition(self.options['in']);
|
|
|
|
},
|
|
|
|
resize: resizeAnnotations,
|
|
|
|
resizeend: resizeendAnnotations,
|
|
|
|
resizecalendar: function(data) {
|
|
|
|
that.triggerEvent('resizecalendar', data);
|
|
|
|
},
|
|
|
|
resizemap: function(data) {
|
|
|
|
that.triggerEvent('resizemap', data);
|
|
|
|
},
|
|
|
|
select: selectAnnotation,
|
|
|
|
toggle: toggleAnnotations,
|
|
|
|
togglecalendar: function(data) {
|
|
|
|
self.options.showAnnotationsCalendar = !data.collapsed;
|
|
|
|
that.triggerEvent('togglecalendar', data);
|
|
|
|
},
|
|
|
|
togglelayer: function(data) {
|
|
|
|
that.triggerEvent('togglelayer', {
|
|
|
|
collapsed: data.collapsed,
|
|
|
|
layer: data.layer
|
|
|
|
});
|
|
|
|
},
|
|
|
|
togglemap: function(data) {
|
|
|
|
self.options.showAnnotationsMap = !data.collapsed;
|
|
|
|
that.triggerEvent('togglemap', data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-17 07:52:37 +00:00
|
|
|
that.setElement(
|
2014-09-24 18:19:25 +00:00
|
|
|
self.$panel = Ox.SplitPanel({
|
2012-04-17 07:52:37 +00:00
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: self.$player
|
|
|
|
},
|
|
|
|
{
|
|
|
|
collapsed: !self.options.showAnnotations,
|
|
|
|
collapsible: true,
|
|
|
|
element: self.$annotationPanel,
|
|
|
|
resizable: true,
|
|
|
|
resize: [192, 256, 320, 384],
|
|
|
|
size: self.options.annotationsSize,
|
2012-09-17 08:36:21 +00:00
|
|
|
tooltip: self.options.annotationsTooltip
|
2012-04-17 07:52:37 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
function getPlayerWidth() {
|
|
|
|
return self.options.width -
|
|
|
|
self.options.showAnnotations * self.options.annotationsSize - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeAnnotations(data) {
|
|
|
|
// called on annotations resize
|
|
|
|
self.options.annotationsSize = data.size;
|
|
|
|
self.$player.options({
|
|
|
|
width: getPlayerWidth()
|
|
|
|
});
|
|
|
|
self.$annotationPanel.options({width: data.size});
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeendAnnotations(data) {
|
|
|
|
that.triggerEvent('annotationssize', data.size);
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeElement(data) {
|
|
|
|
// called on browser toggle
|
|
|
|
self.options.height = data.size;
|
|
|
|
self.$player.options({
|
|
|
|
height: self.options.height
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectAnnotation(data) {
|
|
|
|
self.options.selected = data.id;
|
|
|
|
if (self.options.selected) {
|
|
|
|
setPosition(data['in']);
|
|
|
|
}
|
|
|
|
self.$annotationPanel.options({selected: self.options.selected});
|
|
|
|
that.triggerEvent('select', {id: self.options.selected});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setPosition(position, playing) {
|
2012-06-13 08:28:21 +00:00
|
|
|
var minute = Math.floor(position / 60),
|
|
|
|
previousMinute = Math.floor(self.options.position / 60);
|
2012-04-17 07:52:37 +00:00
|
|
|
self.options.position = position;
|
|
|
|
!playing && self.$player.options({position: self.options.position});
|
|
|
|
self.$annotationPanel.options({position: self.options.position});
|
|
|
|
if (!playing || minute != previousMinute) {
|
|
|
|
that.triggerEvent('position', {
|
|
|
|
position: !playing ? self.options.position : minute * 60
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleAnnotations(data) {
|
|
|
|
self.options.showAnnotations = !data.collapsed;
|
|
|
|
self.$player.options({
|
|
|
|
width: getPlayerWidth()
|
|
|
|
});
|
|
|
|
that.triggerEvent('toggleannotations', {
|
|
|
|
showAnnotations: self.options.showAnnotations
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMuted() {
|
|
|
|
self.$player.toggleMuted();
|
|
|
|
}
|
|
|
|
|
|
|
|
function togglePaused() {
|
|
|
|
self.$player.togglePaused();
|
|
|
|
self.$player.options('paused') && that.triggerEvent('position', {
|
|
|
|
position: self.$player.options('position')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
toggleAnnotations <f> toggle annotations
|
|
|
|
() -> <o> toggle annotations
|
|
|
|
@*/
|
2012-04-17 07:52:37 +00:00
|
|
|
that.toggleAnnotations = function() {
|
2014-09-24 18:19:25 +00:00
|
|
|
self.$panel.toggleElement(1);
|
2012-04-17 07:52:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
};
|