mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-17 16:26:39 +03:00
Seek after clearing a buffer. Workaround for a Chrome bug.
A bug in Chrome makes video feed freeze for a while after a buffer is cleared. Seeking helps to avoid freezing. A bug on Chrome: http://crbug.com/651904 Change-Id: I80d9139cb02e859d9a0165235c9868d9afa8adfa
This commit is contained in:
@@ -348,7 +348,7 @@ shaka.media.Playhead.prototype.onSeeking_ = function() {
|
||||
var targetTime = this.reposition_(currentTime);
|
||||
|
||||
if (Math.abs(targetTime - currentTime) > 0.001) {
|
||||
this.movePlayhead_(currentTime, targetTime);
|
||||
this.movePlayhead(currentTime, targetTime);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ shaka.media.Playhead.prototype.onPlaying_ = function() {
|
||||
var targetTime = this.reposition_(currentTime);
|
||||
|
||||
if (Math.abs(targetTime - currentTime) > 0.001)
|
||||
this.movePlayhead_(currentTime, targetTime);
|
||||
this.movePlayhead(currentTime, targetTime);
|
||||
};
|
||||
|
||||
|
||||
@@ -440,9 +440,8 @@ shaka.media.Playhead.prototype.reposition_ = function(currentTime) {
|
||||
*
|
||||
* @param {number} currentTime
|
||||
* @param {number} targetTime
|
||||
* @private
|
||||
*/
|
||||
shaka.media.Playhead.prototype.movePlayhead_ = function(
|
||||
shaka.media.Playhead.prototype.movePlayhead = function(
|
||||
currentTime, targetTime) {
|
||||
shaka.log.debug('Moving playhead...',
|
||||
'currentTime=' + currentTime,
|
||||
|
||||
@@ -1715,6 +1715,17 @@ shaka.media.StreamingEngine.prototype.clearBuffer_ = function(
|
||||
mediaState.lastSegmentReference = null;
|
||||
mediaState.clearingBuffer = false;
|
||||
this.scheduleUpdate_(mediaState, 0);
|
||||
|
||||
// A workaround for a chrome bug: http://crbug.com/651904
|
||||
// Video freezes for a while after buffer is cleared.
|
||||
// Advancing the playhead a little allows to avoid the freeze.
|
||||
// NOTE: Opera has the same issue as it is based on Chrome.
|
||||
// It also returns true on window.chrome and will unfreeze
|
||||
// after seeking.
|
||||
if (window.chrome) {
|
||||
var currentTime = this.playhead_.getTime();
|
||||
this.playhead_.movePlayhead(currentTime, currentTime + 0.1);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user