-
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
Feature/reset player ui #4683 #5684
Conversation
💖 Thanks for opening this pull request! 💖 Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
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.
We also have #5676 in the pipeline, this PR would need to be fixed up afterwards, though, I'd be happy to help fix any merge issues that occur.
src/js/player.js
Outdated
*/ | ||
resetProgressBar() { | ||
this.currentTime(0); | ||
if (isNaN(this.duration())) { |
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.
as part of #5348, duration can now be NaN, and it's probably more accurate as well.
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.
Thank you for the input. The reason why i added this is that when the duration is NaN, the remaining-time-display does not change or update. Hence setting it to 0. Is there any other way to fix this?
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 think it's more correct to set the duration to NaN
. We should call duration display's update directly here instead.
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.
@gkatsev the thing is if I set it to NaN the remaining time display does not change. Even when calling duration display's update directly.
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.
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.
#5348 is in 7.4.0 and 7.4 is about to be promoted to latest. I can confirm that calling updateContent
on the duration display after setting the duration to NaN
will change the duration display to be -:-
. However, the remaining time display does a null check on the duration. This probably needs to be updated to verify that the duration is a number. So,
video.js/src/js/control-bar/time-controls/remaining-time-display.js
Lines 64 to 66 in f0ba1f5
if (!this.player_.duration()) { | |
return; | |
} |
probably should be something like:
if (typeof this.player_.duration() !== 'number') {
return;
}
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.
Allright, we will also add that change to the PR then. It should be submitted in a couple of hours. Thank you for all the help :)
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.
@gkatsev I think it's done. Anything else please let me know!
src/js/player.js
Outdated
* Reset Control Bar's UI by calling sub-methods that reset | ||
* all of Control Bar's components | ||
*/ | ||
resetControlBarUI() { |
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.
these methods should be suffixed with an _
to show that they're "private" or shouldn't be used directly outside of Video.js.
Also, package-lock changes should probably be backed out. |
Thank you for the input, we will fix these issues ASAP! |
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.
Thanks for this PR! It's extremely helpful!
@gkatsev I think I solved all the problems with this pull request, with the exception of the NaN one because of the above mentioned behaviour. Any other issues with it please let me know so it can be accepted. |
@misteroneill we have implemented the changes you requested. Do you think de PR would eligible to be accepted? |
src/js/player.js
Outdated
*/ | ||
resetProgressBar() { | ||
this.currentTime(0); | ||
if (isNaN(this.duration())) { |
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 think it's more correct to set the duration to NaN
. We should call duration display's update directly here instead.
src/js/player.js
Outdated
this.duration(0); | ||
} | ||
this.tech_.trigger({ type: 'durationchange', target: this.tech_, manuallyTriggered: true }); | ||
this.tech_.trigger({ type: 'timeupdate', target: this.tech_, manuallyTriggered: true }); |
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 guess the duration automatically gets reset to NaN as part of the reset process right now? Also, can However, this is more or less good to go. |
@gkatsev yes it does. I just added the suffix. Ready to go! |
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.
Approving currently but this will likely need changes when the other reset PR is merged in.
Thanks!
Thanks @gkatsev ! Any changes we can help in, let us know |
Looks like there wasn't much conflicts after merging in #5676. I've resolved the conflict via github. |
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.
Thanks!
Congrats on merging your first pull request! 🎉🎉🎉 |
Thanks all! |
@reeckset @imnotteixeira @xRuiAlves I just tried this out in v7.5.0. Looks good, but one thing I noticed is that the loading spinner isn't hidden. So for example, if the content was still loading when |
Description
Solves #4683
Changes
Adds a method in player for resetting its UI (progress bar, volume, playback rate, remaining time display). This is achieved through 3 other new methods to keep a more modular structure. Also created unit tests for this feature, which are passing at the moment.
Besides the mentioned changes, class RemainingTimeDisplay and the player's tech reset unit tests were also modified to fully support the new added changes.
Requirements Checklist