Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: trigger ended when stalling near end of video #105

Closed
wants to merge 1 commit into from

Conversation

forbesjo
Copy link
Contributor

@forbesjo forbesjo commented Jun 29, 2017

Description

Sometimes a player may stall near the end of a video due to some kind of MSE related issue (gap in content for example). This change sets the player into an ended state if we're very near the end of the video and have stalled.

Specific Changes proposed

This change exposes a new option durationTolerance which is the amount of seconds near the end of the video to trigger ended. If the player is within that tolerance and it has started to stall then ended will trigger.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Unit Tests updated or fixed
    • Docs/guides updated
  • Reviewed by Two Core Contributors

@@ -101,6 +102,13 @@ const initPlugin = function(player, options) {
return;
}

// if the player has started to stall and
// playback is almost at the end just end playback
if ((player.duration() - player.currentTime()) < options.durationTolerance) {

Choose a reason for hiding this comment

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

It's a rare case, but I believe it is possible that in HLS, if we start the video the manifest hasn't downloaded, and we can't get a source buffer (or it takes a long time for some reason), this will trigger ended after we get waiting (since duration will return as 0 and current time as 0). Although it is rare, and we can probably resolve it, we may just want to check that duration is > 0 to be safe. I believe the standard for media sources is NaN, which should be fine, but, since different technologies may follow different behaviors when returning a non-existent duration, we may want to have the extra check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, adding the check. I'll also undo the updates to the tests.

@@ -105,9 +111,35 @@ QUnit.test('no progress for 1 second shows the loading spinner', function(assert
);
});

QUnit.test('no progress for 1 near end of video triggers ended', function(assert) {

Choose a reason for hiding this comment

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

1 second

@@ -15,6 +15,7 @@ const defaults = {
timeout: 45 * 1000,
dismiss: defaultDismiss,
progressDisabled: false,
durationTolerance: 0.5,

Choose a reason for hiding this comment

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

Is .5 seconds too high of a duration tolerance? Maybe it isn't, or doesn't matter too much, but I know I've even seen HLS segments where the last one is really short (within that tolerance). Again, it might not matter, and 1 second seems a reasonable amount of time for .5 seconds, but I just wanted to make sure we don't want to start with either a too high of a tolerance and/or too low of a wait time.

Copy link
Contributor Author

@forbesjo forbesjo Jun 30, 2017

Choose a reason for hiding this comment

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

0.5 is an arbitrary low number. For reference here's an issue with a source that stops 0.6 near the end. Again this would only kick in if the player is starting to stall.

shaka-project/shaka-player#913

@forbesjo
Copy link
Contributor Author

Closing, instead going to do this in the source handler since player.trigger('ended') does not do as much as tech.trigger('ended')

@forbesjo forbesjo closed this Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants