diff --git a/source/Ox.UI/js/Video/VideoPlayer.js b/source/Ox.UI/js/Video/VideoPlayer.js index 7f51c55b..08bc3e28 100644 --- a/source/Ox.UI/js/Video/VideoPlayer.js +++ b/source/Ox.UI/js/Video/VideoPlayer.js @@ -286,13 +286,16 @@ Ox.VideoPlayer = function(options, self) { that.bindEvent({ key_0: toggleMuted, key_1: toggleScale, + key_down: function() { + goToNext('chapter', 1); + }, key_equal: function() { changeVolume(0.1); }, key_escape: hideControlMenus, key_f: focusFind, key_g: function() { - goToNextResult(1); + goToNext('result', 1); }, key_left: function() { setPosition(self.options.position - self.secondsPerFrame); @@ -310,7 +313,7 @@ Ox.VideoPlayer = function(options, self) { self.options.enableFullscreen && toggleFullscreen(); }, key_shift_g: function() { - goToNextResult(-1); + goToNext('result', -1); }, key_shift_left: function() { setPosition(self.options.position - 1); @@ -318,7 +321,10 @@ Ox.VideoPlayer = function(options, self) { key_shift_right: function() { setPosition(self.options.position + 1); }, - key_space: togglePaused + key_space: togglePaused, + key_up: function() { + goToNext('chapter', -1); + } }); if (self.options.focus == 'mouseenter') { that.on({ @@ -715,7 +721,7 @@ Ox.VideoPlayer = function(options, self) { } else if (control == 'next') { - self.$nextClipButton = Ox.Button({ + self.$nextChapterButton = Ox.Button({ style: 'video', title: 'arrowRight', tooltip: Ox._('Next'), @@ -723,7 +729,7 @@ Ox.VideoPlayer = function(options, self) { }) .bindEvent({ click: function() { - goToNextChapter(1); + goToNext('chapter', 1); } }) .appendTo(self['$controls' + titleCase]); @@ -838,7 +844,7 @@ Ox.VideoPlayer = function(options, self) { } else if (control == 'previous') { - self.$previousClipButton = Ox.Button({ + self.$previousChapterButton = Ox.Button({ style: 'video', title: 'arrowLeft', tooltip: Ox._('Previous'), @@ -846,7 +852,7 @@ Ox.VideoPlayer = function(options, self) { }) .bindEvent({ click: function() { - goToNextChapter(-1); + goToNext('chapter', -1); } }) .appendTo(self['$controls' + titleCase]); @@ -1050,7 +1056,7 @@ Ox.VideoPlayer = function(options, self) { }) .bindEvent({ click: function() { - goToNextResult(-1); + goToNext('result', -1); } }) .appendTo(self.$find); @@ -1064,7 +1070,7 @@ Ox.VideoPlayer = function(options, self) { }) .bindEvent({ click: function() { - goToNextResult(1); + goToNext('result', 1); } }) .appendTo(self.$find); @@ -1685,63 +1691,25 @@ Ox.VideoPlayer = function(options, self) { return symbol; } - function goToNextChapter(direction) { - var next, - points = self.options.chapters.map(function(chapter) { + function goToNext(type, direction) { + // type can be 'chapter' or 'result' + var position, positions; + if (type == 'chapter') { + positions = self.options.chapters.map(function(chapter) { return chapter.position; - }).concat([self.options.duration]); - if (direction == 1) { - next = points.filter(function(point) { - return point > self.options.position; - })[0]; - } else { - next = points.filter(function(point) { - return point < self.options.position; - }).slice(-1)[0]; + }); + } else if (type == 'result') { + positions = Ox.unique(self.results.map(function(result) { + return result['in']; + })); } - if (Ox.isUndefined(next)) { - next = direction == 1 ? self.options.duration : 0; - if (self.options.loop && next == 0) { - next = points.slice(-2)[0]; - } - } - if (self.options.loop && next == self.options.duration) { - next = 0; - } - setPosition(next); + position = Ox.nextValue(positions, self.options.position, direction); + setPosition(position); that.triggerEvent('position', { position: self.options.position }); } - function goToNextResult(direction) { - var found = false, - 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 - ) { - result = v - found = true; - return false; // break - } - }); - direction == -1 && self.results.reverse(); - if (!found) { - result = self.results[direction == 1 ? 0 : self.results.length - 1]; - } - setPosition(result['in'] + self.secondsPerFrame); - that.triggerEvent('position', { - position: self.options.position - }); - result.id && that.triggerEvent('select', result); - } - } - function goToPoint() { that.triggerEvent('gotopoint'); } @@ -2391,7 +2359,7 @@ Ox.VideoPlayer = function(options, self) { }); if (hasPressedEnter) { if (self.results.length) { - goToNextResult(1); + goToNext('result', 1); that.gainFocus(); } else { self.$findInput.focusInput(true);