fix bugs in video preview

This commit is contained in:
rlx 2012-01-30 20:59:07 +00:00
parent 4e615e722d
commit 70376be049

View file

@ -47,11 +47,9 @@ Ox.VideoPreview = function(options, self) {
// e.offsetX does not work in Firefox // e.offsetX does not work in Firefox
var position = getPosition(event.clientX - that.offset().left); var position = getPosition(event.clientX - that.offset().left);
self.$frame.attr({src: getClosestFrame(position)}); self.$frame.attr({src: getClosestFrame(position)});
Ox.print('closest frame:', self.$frame.attr('src'));
self.timeout && clearTimeout(self.timeout); self.timeout && clearTimeout(self.timeout);
self.timeout = setTimeout(function() { self.timeout = setTimeout(function() {
self.$frame.attr({src: self.options.getFrame(position)}); self.$frame.attr({src: self.options.getFrame(position)});
Ox.print('exact frame:', self.$frame.attr('src'));
}, 250); }, 250);
return Ox.formatDuration(position, 2); return Ox.formatDuration(position, 2);
} }
@ -61,8 +59,8 @@ Ox.VideoPreview = function(options, self) {
click: click, click: click,
mouseenter: startLoading, mouseenter: startLoading,
mouseleave: function() { mouseleave: function() {
self.$frame.attr({src: self.options.getFrame(self.options.position)});
stopLoading(); stopLoading();
self.$frame.attr({src: self.options.getFrame(self.options.position)});
} }
}) })
.appendTo(that.$element); .appendTo(that.$element);
@ -143,6 +141,7 @@ Ox.VideoPreview = function(options, self) {
function stopLoading() { function stopLoading() {
self.queue = []; self.queue = [];
self.timeout && clearTimeout(self.timeout);
} }
self.setOption = function(key, value) { self.setOption = function(key, value) {
@ -153,10 +152,10 @@ Ox.VideoPreview = function(options, self) {
self.$frame.attr({src: self.options.getFrame(value)}); self.$frame.attr({src: self.options.getFrame(value)});
} else if (key == 'width') { } else if (key == 'width') {
that.css({width: value + 'px'}); that.css({width: value + 'px'});
stopLoading();
self.$frame.attr({src: self.options.getFrame()}) self.$frame.attr({src: self.options.getFrame()})
.css(getFrameCSS()); .css(getFrameCSS());
self.$timeline.css({width: value + 'px'}); self.$timeline.css({width: value + 'px'});
stopLoading();
} }
} }