Skip to content

Commit

Permalink
[JW8-2506]Retain pause state when/after seeking (#3283)
Browse files Browse the repository at this point in the history
* remove call to play when _seek is called JW8-2506

* remove call to play when scrubbing on pause

* only cause pause on scrubbing when the player isnt playing

* play if video is completed or the position is less than 1 second away from the duration

* refactor if statement

* Only resume playback on VOD

* remove call to play on seek

* play stream while paused if dvrLive is true

* listen for seeked after live button is pressed to resume playback

* resume playback if state equals playing

* remove listener and call play when going to live edge

* play on idle state and save previous state to check if we should play after scrubbing

* Rename variable, save state before pausing when seeking

* Allow seeking after complete

* Revert seek on complete - bug on ads

* Call play if seeked on complete

* Improve after scrubbing behavior
  • Loading branch information
DanFerrer authored and pajong committed Mar 1, 2019
1 parent 1278236 commit 9101af1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/js/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Object.assign(Controller.prototype, {
let _actionOnAttach;
let _stopPlaylist = false;
let _interruptPlay;
let _resumeAfterScrubbing = null;
let checkAutoStartCancelable = cancelable(_checkAutoStart);
let updatePlaylistCancelable = cancelable(noop);

Expand Down Expand Up @@ -148,8 +149,9 @@ Object.assign(Controller.prototype, {

_model.on('change:scrubbing', function(model, state) {
if (state) {
_resumeAfterScrubbing = _model.get('state') !== STATE_PAUSED;
_pause();
} else {
} else if (_resumeAfterScrubbing) {
_play({ reason: 'interaction' });
}
});
Expand Down Expand Up @@ -642,13 +644,17 @@ Object.assign(Controller.prototype, {
}

function _seek(pos, meta) {
if (_model.get('state') === STATE_ERROR) {
const state = _model.get('state');
if (state === STATE_ERROR) {
return;
}
_programController.position = pos;
if (!_model.get('scrubbing') && _model.get('state') !== STATE_PLAYING) {
meta = meta || {};
meta.startTime = pos;
const isIdle = state === STATE_IDLE;
if (!_model.get('scrubbing') && (isIdle || state === STATE_COMPLETE)) {
if (isIdle) {
meta = meta || {};
meta.startTime = pos;
}
this.play(meta);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/view/controls/controlbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ export default class Controlbar {
// Seek to "Live" position within live buffer, but not before the dvr position which must be negative
const dvrPosition = Math.min(this._model.get('position'), -1);
const dvrSeekLimit = this._model.get('dvrSeekLimit');

this._api.seek(Math.max(-dvrSeekLimit, dvrPosition), reasonInteraction());
this._api.play(reasonInteraction());
}
}

Expand Down

0 comments on commit 9101af1

Please sign in to comment.