Skip to content

Commit

Permalink
Merge pull request #383 from fmtvp/live_seekable_pause_guard
Browse files Browse the repository at this point in the history
For seekable live devices, do not pause if near start of seekable range.
  • Loading branch information
cloud1ess authored Sep 6, 2016
2 parents 1297e2c + 1366bf6 commit 30cb398
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions static/script/devices/mediaplayer/live/seekable.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,21 @@ define(
},

pause: function (opts) {
this._mediaPlayer.pause();
opts = opts || {};
if(opts.disableAutoResume !== true){
this._autoResumeAtStartOfRange();
var secondsUntilStartOfWindow = this._mediaPlayer.getCurrentTime() - this._mediaPlayer.getSeekableRange().start;
if (secondsUntilStartOfWindow > AUTO_RESUME_WINDOW_START_CUSHION_SECONDS) {
this._mediaPlayer.pause();
opts = opts || {};
if(opts.disableAutoResume !== true){
this._autoResumeAtStartOfRange();
}
} else {
// 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();
}
},

resume: function () {
this._mediaPlayer.resume();
},
Expand Down Expand Up @@ -135,12 +143,12 @@ define(

_autoResumeAtStartOfRange: function () {
var self = this;
var timeUntilStartOfWindow = Math.max(0, this._mediaPlayer.getCurrentTime() - this._mediaPlayer.getSeekableRange().start - AUTO_RESUME_WINDOW_START_CUSHION_SECONDS);
var secondsUntilAutoResume = Math.max(0, this._mediaPlayer.getCurrentTime() - this._mediaPlayer.getSeekableRange().start - AUTO_RESUME_WINDOW_START_CUSHION_SECONDS);

var autoResumeTimer = setTimeout(function () {
self.removeEventCallback(self, detectIfUnpaused);
self.resume();
}, timeUntilStartOfWindow * 1000);
}, secondsUntilAutoResume * 1000);

this.addEventCallback(this, detectIfUnpaused);
function detectIfUnpaused(event) {
Expand Down

0 comments on commit 30cb398

Please sign in to comment.