-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Make inactivity timeout configurable #1409
Conversation
Seems reasonable to me. |
Yep, seems reasonable to me too. Unless @heff has objections, we'll pull this one in soon. |
@@ -1624,7 +1624,7 @@ vjs.Player.prototype.listenForUserActivity = function(){ | |||
if (!this.userActivity_) { | |||
this.userActive(false); | |||
} | |||
}), 2000); | |||
}), vjs.options['inactivityTimeout']); |
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.
Actually, this should probably check the current player's options for inactivityTimeout
so that you can have different players with different timeouts.
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.
I have not dug into the code enough yet to know how to do that, but I'll take a look tomorrow.
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.
Should be something like this.options()['inactivityTimeout']
Completely disabling the timeout (see #1213) would be trivial to add, perhaps by setting |
Just realized |
To disable it, just set it to 0. |
If |
This looks great, thanks Andreas! Any chance you want to try and write a test for this? There's not an existing one so it might be a challenge, but let me know if you want to try. |
@heff I added a test to check the different |
Looks like we should pull in sinon's fake timers for this test. Asyncornous tests are always flaky. sinon's fake timers allow you to control time in your tests which will make them run faster and more reliably. |
@gkatsev I was not aware of that library, thanks! |
player = PlayerTest.makePlayer({}); | ||
html5Mock = { player_: player }; | ||
|
||
vjs.Html5.prototype.createEl.call(html5Mock); |
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 the html5mock part needed here?
Tests look great, thanks! |
@gkatsev is zero the right setting here to disable it or should we use |
@heff removed unneeded html5Mock code |
Thanks Andreas! |
This PR is for issue #1408 and makes the inactivity timeout configurable, so e.g. the controls can be hidden quicker or slower than the default 2000 ms: