forked from 0x2620/oxjs
fix #1891 (update subtitles on edit)
This commit is contained in:
parent
cd5b1ac367
commit
0873d27f92
3 changed files with 22 additions and 21 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// FIXME: should be Ox.AnnotationFolders
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.AnnotationPanel <f> Video Annotation Panel
|
Ox.AnnotationPanel <f> Video Annotation Panel
|
||||||
options <o> Options object
|
options <o> Options object
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
||||||
out: self.options.out,
|
out: self.options.out,
|
||||||
results: self.options.results,
|
results: self.options.results,
|
||||||
state: self.options.state,
|
state: self.options.state,
|
||||||
subtitles: self.options.subtitles,
|
subtitles: Ox.clone(self.options.subtitles, true),
|
||||||
type: self.options.type,
|
type: self.options.type,
|
||||||
width: Math.round(self.options.duration)
|
width: Math.round(self.options.duration)
|
||||||
});
|
});
|
||||||
|
|
@ -275,7 +275,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSubtitles() {
|
function setSubtitles() {
|
||||||
self.$image.options({subtitles: self.options.subtitles});
|
self.$image.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||||
updateTimelines();
|
updateTimelines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
showMarkers: true,
|
showMarkers: true,
|
||||||
showMilliseconds: 3,
|
showMilliseconds: 3,
|
||||||
sizeIsLarge: self.options.videoSize == 'large',
|
sizeIsLarge: self.options.videoSize == 'large',
|
||||||
subtitles: Ox.clone(self.options.subtitles),
|
subtitles: Ox.clone(self.options.subtitles, true),
|
||||||
type: type,
|
type: type,
|
||||||
video: type == 'play' ? self.options.video : self.options.getFrameURL,
|
video: type == 'play' ? self.options.video : self.options.getFrameURL,
|
||||||
volume: self.options.volume,
|
volume: self.options.volume,
|
||||||
|
|
@ -413,7 +413,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
//matches: self.options.matches,
|
//matches: self.options.matches,
|
||||||
out: self.options.out,
|
out: self.options.out,
|
||||||
position: self.options.position,
|
position: self.options.position,
|
||||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : [],
|
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : [],
|
||||||
type: self.options.timeline,
|
type: self.options.timeline,
|
||||||
width: self.sizes.timeline[0].width
|
width: self.sizes.timeline[0].width
|
||||||
})
|
})
|
||||||
|
|
@ -443,7 +443,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
results: find(self.options.find),
|
results: find(self.options.find),
|
||||||
showPointMarkers: true,
|
showPointMarkers: true,
|
||||||
state: self.options.selected ? 'selected' : 'default',
|
state: self.options.selected ? 'selected' : 'default',
|
||||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : [],
|
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : [],
|
||||||
type: self.options.timeline,
|
type: self.options.timeline,
|
||||||
videoId: self.options.videoId,
|
videoId: self.options.videoId,
|
||||||
width: self.sizes.timeline[1].width
|
width: self.sizes.timeline[1].width
|
||||||
|
|
@ -1026,19 +1026,19 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedLayer() {
|
function getSelectedLayer() {
|
||||||
var layer;
|
var selectedLayer;
|
||||||
Ox.forEach(self.options.layers, function(layer) {
|
Ox.forEach(self.options.layers, function(layer) {
|
||||||
Ox.forEach(layer.items, function(item) {
|
Ox.forEach(layer.items, function(item) {
|
||||||
if (item.id == self.options.selected) {
|
if (item.id == self.options.selected) {
|
||||||
layer = layer.id;
|
selectedLayer = layer.id;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (layer) {
|
if (selectedLayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return layer;
|
return selectedLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSizes(scrollbarIsVisible) {
|
function getSizes(scrollbarIsVisible) {
|
||||||
|
|
@ -1112,7 +1112,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
function getSubtitles() {
|
function getSubtitles() {
|
||||||
return self.options.subtitlesLayer ? self.options.layers.filter(function(layer) {
|
return self.options.subtitlesLayer ? self.options.layers.filter(function(layer) {
|
||||||
return layer.id == self.options.subtitlesLayer;
|
return layer.id == self.options.subtitlesLayer;
|
||||||
})[0].map(function(subtitle) {
|
})[0].items.map(function(subtitle) {
|
||||||
return {
|
return {
|
||||||
id: subtitle.id,
|
id: subtitle.id,
|
||||||
'in': subtitle['in'],
|
'in': subtitle['in'],
|
||||||
|
|
@ -1253,12 +1253,6 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
if (self.options['in'] > self.options.out) {
|
if (self.options['in'] > self.options.out) {
|
||||||
setPoint(point == 'in' ? 'out' : 'in', position, keepSelected);
|
setPoint(point == 'in' ? 'out' : 'in', position, keepSelected);
|
||||||
} else {
|
} else {
|
||||||
if (
|
|
||||||
self.options.selected && self.options.subtitlesLayer
|
|
||||||
&& getSelectedLayer() == self.options.subtitlesLayer
|
|
||||||
) {
|
|
||||||
updateSubtitles();
|
|
||||||
}
|
|
||||||
self.$annotationPanel.options({
|
self.$annotationPanel.options({
|
||||||
'in': self.options['in'],
|
'in': self.options['in'],
|
||||||
out: self.options.out
|
out: self.options.out
|
||||||
|
|
@ -1468,7 +1462,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
});
|
});
|
||||||
self.$timeline.forEach(function($timeline) {
|
self.$timeline.forEach(function($timeline) {
|
||||||
$timeline.options({
|
$timeline.options({
|
||||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : []
|
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
that.triggerEvent('subtitles', {
|
that.triggerEvent('subtitles', {
|
||||||
|
|
@ -1479,12 +1473,14 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
function updateSubtitles() {
|
function updateSubtitles() {
|
||||||
self.options.subtitles = getSubtitles();
|
self.options.subtitles = getSubtitles();
|
||||||
self.$player.forEach(function($player) {
|
self.$player.forEach(function($player) {
|
||||||
player.options({subtitles: self.options.subtitles});
|
$player.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||||
});
|
});
|
||||||
|
if (self.options.enableSubtitles) {
|
||||||
self.$timeline.forEach(function($timeline) {
|
self.$timeline.forEach(function($timeline) {
|
||||||
$timeline.options({subtitles: self.options.subtitles});
|
$timeline.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateTimelines() {
|
function updateTimelines() {
|
||||||
self.$timeline.forEach(function($timeline) {
|
self.$timeline.forEach(function($timeline) {
|
||||||
|
|
@ -1548,6 +1544,9 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
||||||
that.updateAnnotation = function(id, annotation) {
|
that.updateAnnotation = function(id, annotation) {
|
||||||
// called from editannotation callback
|
// called from editannotation callback
|
||||||
self.options.selected = annotation.id; // fixme: needed?
|
self.options.selected = annotation.id; // fixme: needed?
|
||||||
|
if (getSelectedLayer() == self.options.subtitlesLayer) {
|
||||||
|
updateSubtitles();
|
||||||
|
}
|
||||||
self.$annotationPanel.updateItem(id, annotation);
|
self.$annotationPanel.updateItem(id, annotation);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue