fix seeking event for multipart videos that load at the beginning of a part, fixes #3065
This commit is contained in:
parent
c02a08c8d9
commit
de72a11364
1 changed files with 33 additions and 14 deletions
|
@ -346,38 +346,57 @@ Ox.VideoElement = function(options, self) {
|
||||||
self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length);
|
self.currentVideo = Ox.mod(self.currentVideo + 1, self.$videos.length);
|
||||||
self.$video = self.$videos[self.currentVideo];
|
self.$video = self.$videos[self.currentVideo];
|
||||||
self.video = self.$video[0];
|
self.video = self.$video[0];
|
||||||
|
self.video.muted = true; // avoid sound glitch during load
|
||||||
if (self.$video.attr('src') != item.src) {
|
if (self.$video.attr('src') != item.src) {
|
||||||
self.loadedMetadata && Ox.Log('Video', 'caching next item failed, reset src');
|
self.loadedMetadata && Ox.Log('Video', 'caching next item failed, reset src');
|
||||||
self.video.src = item.src;
|
self.video.src = item.src;
|
||||||
self.video.preload = 'auto';
|
self.video.preload = 'auto';
|
||||||
}
|
}
|
||||||
self.video.volume = getVolume();
|
self.video.volume = getVolume();
|
||||||
self.video.muted = muted;
|
|
||||||
self.video.playbackRate = self.options.playbackRate;
|
self.video.playbackRate = self.options.playbackRate;
|
||||||
self.$video.css(css);
|
self.$video.css(css);
|
||||||
self.buffering = true;
|
self.buffering = true;
|
||||||
Ox.Log('Video', 'sCV', self.video.src, item['in'],
|
Ox.Log('Video', 'sCV', self.video.src, item['in'],
|
||||||
self.video.currentTime, self.video.seeking);
|
self.video.currentTime, self.video.seeking);
|
||||||
isReady(self.$video, function(video) {
|
isReady(self.$video, function(video) {
|
||||||
self.$video.one('seeked', function() {
|
var in_ = item['in'] || 0;
|
||||||
Ox.Log('Video', 'sCV', 'seeked callback');
|
|
||||||
|
function ready() {
|
||||||
|
Ox.Log('Video', 'sCV', 'ready');
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
|
self.video.muted = muted;
|
||||||
!self.paused && self.video.play();
|
!self.paused && self.video.play();
|
||||||
self.$video.show();
|
self.$video.show();
|
||||||
callback && callback();
|
callback && callback();
|
||||||
loadNextVideo();
|
loadNextVideo();
|
||||||
|
}
|
||||||
|
if (video.currentTime == in_) {
|
||||||
|
Ox.Log('Video', 'sCV', 'already at position');
|
||||||
|
self.seeking = false;
|
||||||
|
ready();
|
||||||
|
} else {
|
||||||
|
self.$video.one('seeked', function() {
|
||||||
|
Ox.Log('Video', 'sCV', 'seeked callback');
|
||||||
|
ready();
|
||||||
});
|
});
|
||||||
if (!self.seeking) {
|
if (!self.seeking) {
|
||||||
Ox.Log('Video', 'sCV set in', video.src, item['in'] || 0, video.currentTime, video.seeking);
|
Ox.Log('Video', 'sCV set in', video.src, in_, video.currentTime, video.seeking);
|
||||||
video.currentTime = item['in'] || 0;
|
self.seeking = true;
|
||||||
|
video.currentTime = in_;
|
||||||
if (self.paused) {
|
if (self.paused) {
|
||||||
var promise = self.video.play();
|
var promise = self.video.play();
|
||||||
if (promise) {
|
if (promise !== undefined) {
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
self.video.pause();
|
self.video.pause();
|
||||||
|
self.video.muted = muted;
|
||||||
|
}).catch(function() {
|
||||||
|
self.video.pause();
|
||||||
|
self.video.muted = muted;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.video.pause();
|
self.video.pause();
|
||||||
|
self.video.muted = muted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue