From 90085aaf2fd10fb7ed75948420011023552b7a6b Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Mon, 3 Oct 2011 10:59:09 +0000 Subject: [PATCH] add rewind option to video player --- source/Ox.UI/js/Video/Ox.VideoPlayer.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/Ox.UI/js/Video/Ox.VideoPlayer.js b/source/Ox.UI/js/Video/Ox.VideoPlayer.js index 5b547530..9ce93cd7 100644 --- a/source/Ox.UI/js/Video/Ox.VideoPlayer.js +++ b/source/Ox.UI/js/Video/Ox.VideoPlayer.js @@ -44,6 +44,7 @@ Ox.VideoPlayer Generic Video Player preload 'auto', 'metadata' or 'none' out Out point (sec) resolution resolution + rewind If true, video will rewind when ended scaleToFill If true, scale to fill (otherwise, scale to fit) showControlsOnLoad If true, show controls on load showFind If true, show find input @@ -104,6 +105,7 @@ Ox.VideoPlayer = function(options, self) { preload: 'auto', out: 0, resolution: 0, + rewind: false, scaleToFill: false, showControlsOnLoad: false, showFind: false, @@ -1033,6 +1035,7 @@ Ox.VideoPlayer = function(options, self) { }, 250); self.iconIsVisible = true; } + self.options.rewind && rewind(); } function find(query) { @@ -1547,9 +1550,14 @@ Ox.VideoPlayer = function(options, self) { self.$video.playNext(); } else { togglePaused(); - setPosition(self.playInToOut ? self.options.out : self.out/*, 'video'*/); - //ended(); self.playInToOut = false; + if (self.options.rewind) { + rewind(); + } else { + setPosition(self.playInToOut ? self.options.out : self.out/*, 'video'*/); + } + //ended(); + that.triggerEvent('ended'); } } else { setPosition(self.options.position, 'video'); @@ -1590,6 +1598,12 @@ Ox.VideoPlayer = function(options, self) { }); } + function rewind() { + setTimeout(function() { + setPosition(self.options.playInToOut ? self.options.in : 0); + }, 250); + } + function seeked() { Ox.print('XX seeked') clearTimeout(self.seekTimeout);