diff --git a/lib/media/playhead.js b/lib/media/playhead.js index ac8958fe2..39f890590 100644 --- a/lib/media/playhead.js +++ b/lib/media/playhead.js @@ -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, diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index 44683fae4..87b86a3ac 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -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)); };