Skip to content

Commit

Permalink
Merge pull request #387 from fmtvp/allow_disable_auto_resume_near_sta…
Browse files Browse the repository at this point in the history
…rt_of_seekable_range

Honor 'disableAutoResume' pause option in live seekable facade near start of seekable range.
  • Loading branch information
JohnBogart authored Sep 12, 2016
2 parents 30cb398 + 26f880e commit bb35c0a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
43 changes: 43 additions & 0 deletions static/script-tests/tests/devices/mediaplayer/live/seekable.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,49 @@
}, config);
};

this.LivePlayerSupportLevelSeekableTest.prototype.testSeekableLivePlayerPauseFakesImmediateAutoResumeNearStartOfSeekableRange = function (queue) {
queuedApplicationInit(queue, 'lib/mockapplication', ['antie/devices/mediaplayer/mediaplayer', 'antie/devices/device', 'antie/devices/mediaplayer/live/seekable'], function (application, MediaPlayer, Device) {
var device = new Device(antie.framework.deviceConfiguration);
var livePlayer = device.getLivePlayer();
var expectedRange = {
'start': 0,
'end': 30
};
this.sandbox.stub(livePlayer._mediaPlayer, 'getSeekableRange').returns(expectedRange);
this.sandbox.stub(livePlayer._mediaPlayer, 'getCurrentTime').returns(8);
var toPausedStub = this.sandbox.stub(livePlayer._mediaPlayer, '_toPaused');
var toPlayingStub = this.sandbox.stub(livePlayer._mediaPlayer, '_toPlaying');
var pauseStub = this.sandbox.stub(livePlayer._mediaPlayer, 'pause');

livePlayer.pause();
assert(pauseStub.notCalled);
assert(toPausedStub.calledOnce);
assert(toPlayingStub.calledOnce);
sinon.assert.callOrder(toPausedStub, toPlayingStub);
}, config);
};

this.LivePlayerSupportLevelSeekableTest.prototype.testSeekableLivePlayerPauseDoesNotFakeImmediateAutoResumeIfDisabledNearStartOfSeekableRange = function (queue) {
queuedApplicationInit(queue, 'lib/mockapplication', ['antie/devices/mediaplayer/mediaplayer', 'antie/devices/device', 'antie/devices/mediaplayer/live/seekable'], function (application, MediaPlayer, Device) {
var device = new Device(antie.framework.deviceConfiguration);
var livePlayer = device.getLivePlayer();
var expectedRange = {
'start': 0,
'end': 30
};
this.sandbox.stub(livePlayer._mediaPlayer, 'getSeekableRange').returns(expectedRange);
this.sandbox.stub(livePlayer._mediaPlayer, 'getCurrentTime').returns(8);
var toPausedStub = this.sandbox.stub(livePlayer._mediaPlayer, '_toPaused');
var toPlayingStub = this.sandbox.stub(livePlayer._mediaPlayer, '_toPlaying');
var pauseStub = this.sandbox.stub(livePlayer._mediaPlayer, 'pause');

livePlayer.pause({disableAutoResume: true});
assert(pauseStub.calledOnce);
assert(toPausedStub.notCalled);
assert(toPlayingStub.notCalled);
}, config);
};

this.LivePlayerSupportLevelSeekableTest.prototype.testSeekableLivePlayerResumeCallsFunctionInMediaPlayer = testFunctionsInLivePlayerCallMediaPlayerFunctions('resume', 0);

this.LivePlayerSupportLevelSeekableTest.prototype.testSeekableLivePlayerGetCurrentTimeCallsFunctionInMediaPlayer = testFunctionsInLivePlayerCallMediaPlayerFunctions('getCurrentTime', 0);
Expand Down
13 changes: 7 additions & 6 deletions static/script/devices/mediaplayer/live/seekable.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,20 @@ define(
},

pause: function (opts) {
opts = opts || {};
var secondsUntilStartOfWindow = this._mediaPlayer.getCurrentTime() - this._mediaPlayer.getSeekableRange().start;
if (secondsUntilStartOfWindow > AUTO_RESUME_WINDOW_START_CUSHION_SECONDS) {

if (opts.disableAutoResume) {
this._mediaPlayer.pause();
opts = opts || {};
if(opts.disableAutoResume !== true){
this._autoResumeAtStartOfRange();
}
} else {
} else if (secondsUntilStartOfWindow <= AUTO_RESUME_WINDOW_START_CUSHION_SECONDS) {
// IPLAYERTVV1-4166
// We can't pause so close to the start of the sliding window, so do a quick state transition in and
// out on 'pause' state to be consistent with the rest of TAL.
this._mediaPlayer._toPaused();
this._mediaPlayer._toPlaying();
} else {
this._mediaPlayer.pause();
this._autoResumeAtStartOfRange();
}
},
resume: function () {
Expand Down

0 comments on commit bb35c0a

Please sign in to comment.