Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Fix resuming live playback after long pauses #1006

Merged
merged 15 commits into from
Feb 21, 2017

Conversation

gesinger
Copy link
Contributor

Description

After a live video is paused long enough that the playlist no longer contains any segments previously requested, our seekable range is off and we often can't resume playback. This was for two primary reasons: (1) we were not updating seekable after the playlist updated enough that we no longer had any known segments and (2) if the segment times did not match up perfectly with the specified durations in the playlist, our seekable range would be off and we'd never try to adjust after seeking.

Specific Changes proposed

This seeks to resolve resuming live playback by keeping the seekable range updated, and checking to see if we are outside of a seekable range when we resume (after getting new sync info).

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

src/ranges.js Outdated

for (let i = 0; i < range.length; i++) {
if (i > 0) {
str += ', ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid this if you make str and array pushing each start+end and return str.join(','). (It's also better for performance, not that these ranges will ever be large enough for that to matter)

this.player.tech_.trigger('waiting');
assert.equal(seeks.length, 2, 'did not seek');

// no check for 0 with seekable false because that should be handled by live falloff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seekable -> seeking

@@ -79,6 +79,12 @@ export default class PlaybackWatcher {
* @private
*/
checkCurrentTime_() {
if (this.tech_.seeking() && this.fixBadSeeks_()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please, please rename fixBadSeeks_ to fixesBadSeeks_ because that would make me soooo happy.

let seekable = this.seekable();
let currentTime = this.tech_.currentTime();

if (this.tech_.seeking() &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably safer to leave this check in here, just thought I'd note that I don't think we can get into this function with seeking is false since the check this.tech_.seeking() && this.fixBadSeeks_() won't call fixBadSeeks_ if seeking returns false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a tough one to decide between.

@@ -123,6 +154,10 @@ export default class PlaybackWatcher {
let seekable = this.seekable();
let currentTime = this.tech_.currentTime();

if (this.tech_.seeking() && this.fixBadSeeks_()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check made in both checkCurrentTime_ and waiting_?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The waiting event can fire and cause waiting_ to run independent of checkCurrentTime_

let seekable = this.seekable();
let currentTime = this.tech_.currentTime();

if (this.tech_.seeking() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function ever run in VOD?

It seems wise to check to see if the duration is "Infinity" before taking any other measures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its bad to have this for VOD. Seekable doesn't change in VOD anyway, so if someone tries seeking outside of the duration of the video, this would just adjust it to 0 or end of video depending on which direction they overseeked

@imbcmdth
Copy link
Member

LGTM!

imbcmdth added a commit that referenced this pull request Feb 23, 2017
…oor-guess behaviors (#1023)

* Fix a bug with the combination of seek-to-live (#1006) and resync-on-a-poor-guess (#1016) behaviors

* Added tests to ensure the proper sequence of events for seekable and resync logic

* Unregister the seekablechanged event handler from the tech on dispose
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants