From ecc1f8027908e5e582853889d09639f05737a50b Mon Sep 17 00:00:00 2001 From: Timothy Drews Date: Mon, 20 Apr 2015 14:13:00 -0700 Subject: [PATCH] Don't go into a buffering state while paused. Closes #61 Change-Id: I46ce7b97b6058797ba643b77ccf72399dadc9765 --- lib/player/player.js | 6 ++++-- spec/player_integration.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/player/player.js b/lib/player/player.js index ff46822ed3..966e00e9c3 100644 --- a/lib/player/player.js +++ b/lib/player/player.js @@ -848,8 +848,10 @@ shaka.player.Player.prototype.onWatchdogTimer_ = function() { var fudgedBufferEnd = bufferEnd + shaka.player.Player.BUFFERED_FUDGE_FACTOR_; if (!this.buffering_) { - // Don't go into a buffering state at the end of the video. - if (fudgedBufferEnd < this.video_.duration && buffered < threshold) { + // Don't go into a buffering state while paused or when at the end of the + // video. + if ((fudgedBufferEnd < this.video_.duration && buffered < threshold) && + !this.video_.paused) { this.enterBufferingState_(); } } else { diff --git a/spec/player_integration.js b/spec/player_integration.js index 88fedd2d09..7d01ce2841 100644 --- a/spec/player_integration.js +++ b/spec/player_integration.js @@ -722,6 +722,36 @@ describe('Player', function() { }); }); + it('respects autoplay=true', function(done) { + video.autoplay = true; + + player.load(newSource(plainManifest)).then(function() { + return waitForMovement(); + }).then(function() { + expect(video.currentTime).toBeGreaterThan(0.0); + expect(video.paused).toBe(false); + done(); + }).catch(function(error) { + fail(error); + done(); + }); + }); + + it('respects autoplay=false', function(done) { + video.autoplay = false; + + player.load(newSource(plainManifest)).then(function() { + return delay(4); + }).then(function() { + expect(video.currentTime).toBe(0); + expect(video.paused).toBe(true); + done(); + }).catch(function(error) { + fail(error); + done(); + }); + }); + // TODO(story 1970528): add tests which exercise PSSH parsing, // SegmentTemplate resolution, and SegmentList generation.