-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closing, instead going to do this in the source handler since |
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 triggerended
. If the player is within that tolerance and it has started to stall thenended
will trigger.Requirements Checklist