video player: add keyboard shortcut and public method for loop, abort play-in-to-out on pause, minor cleanup

This commit is contained in:
rlx 2013-08-01 08:39:20 +00:00
parent f7cbbb689f
commit 4eab471f9d

View file

@ -297,15 +297,14 @@ Ox.VideoPlayer = function(options, self) {
key_g: function() { key_g: function() {
goToNext('result', 1); goToNext('result', 1);
}, },
key_l: toggleLoop,
key_left: function() { key_left: function() {
setPosition(self.options.position - self.secondsPerFrame); setPosition(self.options.position - self.secondsPerFrame);
}, },
key_minus: function() { key_minus: function() {
changeVolume(-0.1); changeVolume(-0.1);
}, },
key_p: function() { key_p: playInToOut,
playInToOut();
},
key_right: function() { key_right: function() {
setPosition(self.options.position + self.secondsPerFrame); setPosition(self.options.position + self.secondsPerFrame);
}, },
@ -1788,6 +1787,11 @@ Ox.VideoPlayer = function(options, self) {
return str.slice(0, -1).match(/^\d+$/) && str.slice(-1) == 'p'; return str.slice(0, -1).match(/^\d+$/) && str.slice(-1) == 'p';
} }
function itemchange(data) {
var item = self.$video.options('items')[data.item];
Ox.Log('Video', 'ITEMCHANGE', item);
}
function loadImage() { function loadImage() {
self.$image self.$image
.one({ .one({
@ -1895,8 +1899,6 @@ Ox.VideoPlayer = function(options, self) {
} else { } else {
setPosition(self.playInToOut ? self.options.out : self.out/*, 'video'*/); setPosition(self.playInToOut ? self.options.out : self.out/*, 'video'*/);
} }
self.playInToOut = false;
//ended();
that.triggerEvent('ended'); that.triggerEvent('ended');
} }
} else { } else {
@ -1915,11 +1917,6 @@ Ox.VideoPlayer = function(options, self) {
} }
} }
function itemchange(data) {
var item = self.$video.options('items')[data.item];
Ox.Log('Video', 'ITEMCHANGE', item);
}
function progress() { function progress() {
var buffered = self.$video.buffered(); var buffered = self.$video.buffered();
for (var i = 0; i < buffered.length; i++) { for (var i = 0; i < buffered.length; i++) {
@ -2522,6 +2519,7 @@ Ox.VideoPlayer = function(options, self) {
opacity: 1 opacity: 1
}, 250); }, 250);
} }
self.playInToOut = false;
} else { } else {
if (self.options.playInToOut && self.options.position > self.options.out - self.secondsPerFrame) { if (self.options.playInToOut && self.options.position > self.options.out - self.secondsPerFrame) {
setPosition(self.options['in']); setPosition(self.options['in']);
@ -2613,6 +2611,15 @@ Ox.VideoPlayer = function(options, self) {
return that; return that;
}; };
/*@
togglePaused <f> toggle loop state
() -> <o> toggle loop state
@*/
that.toggleLoop = function() {
toggleLoop();
return that;
};
/*@ /*@
togglePaused <f> toggle paused state togglePaused <f> toggle paused state
() -> <o> toggle paused state () -> <o> toggle paused state
@ -2620,7 +2627,7 @@ Ox.VideoPlayer = function(options, self) {
that.togglePaused = function() { that.togglePaused = function() {
togglePaused(); togglePaused();
return that; return that;
} };
/*@ /*@
toggleMuted <f> toggle muted state toggleMuted <f> toggle muted state
@ -2629,7 +2636,7 @@ Ox.VideoPlayer = function(options, self) {
that.toggleMuted = function() { that.toggleMuted = function() {
toggleMuted(); toggleMuted();
return that; return that;
} };
return that; return that;