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:
Sandra Lokshina
2016-09-30 13:16:49 -07:00
parent c17b1f1610
commit 10b3dd0a7e
2 changed files with 14 additions and 4 deletions
+3 -4
View File
@@ -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,
+11
View File
@@ -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));
};