1
0
Fork 0
forked from 0x2620/oxjs

fix issues with automatically opening annotation folders; add annotations option to video player to make find work for all layers

This commit is contained in:
rlx 2012-02-19 10:49:52 +00:00
commit 94cfbdb45c
7 changed files with 108 additions and 30 deletions

View file

@ -6,12 +6,11 @@
Ox.VideoPlayer <f> Generic Video Player
(options, self) -> <o> Video Player
options <o> Options
annotation <[o]> Array of annotation tracks
name <s> Name of the annotation track
data <[o]> Annotation data
in <n> In point (sec)
out <n> Out point (sec)
text <s> Text
annotations <[]> Array of annotations
id <s> Optional id
in <n> In point (sec)
out <n> Out point (sec)
text <s> Text
censored <a|[]> Array of censored ranges
controlsBottom <[s]|[]> Bottom controls, from left to right
Can be 'close', fullscreen', 'scale', 'title', 'find', 'open',
@ -60,6 +59,7 @@ Ox.VideoPlayer <f> Generic Video Player
showProgress <|false> If true, show buffering progress
sizeIsLarge <b|false> If true, initial state of the size control is large
subtitles <s|[o]|[]> URL or SRT or array of subtitles
id <s> Optional id
in <n> In point (sec)
out <n> Out point (sec)
text <s> Text
@ -146,6 +146,10 @@ Ox.VideoPlayer = function(options, self) {
}
});
if (Ox.isEmpty(self.options.annotations)) {
self.options.annotations = self.options.subtitles;
}
if (Ox.isObject(self.options.video)) {
self.resolutions = Ox.sort(Object.keys(self.options.video));
if (!(self.options.resolution in self.options.video)) {
@ -1160,13 +1164,17 @@ Ox.VideoPlayer = function(options, self) {
var results = [];
if (query.length) {
query = query.toLowerCase();
results = Ox.map(self.options.subtitles, function(subtitle) {
return subtitle.text.toLowerCase().indexOf(query) > -1 ? {
'in': subtitle['in'],
out: subtitle.out
results = Ox.map(self.options.annotations, function(annotation) {
return Ox.decodeHTML(Ox.stripTags(
annotation.text.toLowerCase()
)).indexOf(query) > -1 ? {
id: annotation.id,
'in': annotation['in'],
out: annotation.out
} : null;
});
}
Ox.print('FIND RESULTS:', results);
return results;
}
@ -1500,24 +1508,29 @@ Ox.VideoPlayer = function(options, self) {
function goToNextResult(direction) {
var found = false,
position = 0;
result;
if (self.results.length) {
direction == -1 && self.results.reverse();
Ox.forEach(self.results, function(v) {
if (direction == 1 ? v['in'] > self.options.position : v.out < self.options.position) {
position = v['in'];
if (
direction == 1
? v['in'] > self.options.position
: v.out < self.options.position
) {
result = v
found = true;
return false;
}
});
direction == -1 && self.results.reverse();
if (!found) {
position = self.results[direction == 1 ? 0 : self.results.length - 1]['in'];
result = self.results[direction == 1 ? 0 : self.results.length - 1];
}
setPosition(position + self.secondsPerFrame);
setPosition(result['in'] + self.secondsPerFrame);
that.triggerEvent('position', {
position: self.options.position
});
result.id && that.triggerEvent('select', result);
}
}
@ -2132,7 +2145,12 @@ Ox.VideoPlayer = function(options, self) {
results: self.results
});
if (hasPressedEnter) {
self.results.length ? goToNextResult(1) : self.$findInput.focusInput(true);
if (self.results.length) {
goToNextResult(1);
that.gainFocus();
} else {
self.$findInput.focusInput(true);
}
}
that.triggerEvent('find', {find: self.options.find});
}