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

Feature/reset player ui #4683 #5684

Merged
merged 12 commits into from
Jan 8, 2019
Merged

Conversation

reeckset
Copy link
Contributor

@reeckset reeckset commented Dec 13, 2018

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

  • Feature implemented
  • Tested in multiple browsers
  • Test cases passed
  • Reviewed by Two Core Contributors

@welcome
Copy link

welcome bot commented Dec 13, 2018

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

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.

Copy link
Member

@gkatsev gkatsev left a 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())) {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

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

From our analysis, PR #5348 would make setting the duration to NaN update the duration display. Therefore, if this PR follows #5348, setting the duration to NaN will trigger the update in the remaining time display

Copy link
Member

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,

if (!this.player_.duration()) {
return;
}

probably should be something like:

if (typeof this.player_.duration() !== 'number') {
  return;
}

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 :)

Copy link
Contributor Author

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() {
Copy link
Member

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.

@gkatsev
Copy link
Member

gkatsev commented Dec 13, 2018

Also, package-lock changes should probably be backed out.

@xRuiAlves
Copy link

Thank you for the input, we will fix these issues ASAP!

Copy link
Member

@misteroneill misteroneill left a 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!

src/js/player.js Outdated Show resolved Hide resolved
@reeckset
Copy link
Contributor Author

@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.

@xRuiAlves
Copy link

@misteroneill we have implemented the changes you requested. Do you think de PR would eligible to be accepted?

src/js/player.js Outdated Show resolved Hide resolved
src/js/player.js Outdated
*/
resetProgressBar() {
this.currentTime(0);
if (isNaN(this.duration())) {
Copy link
Member

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 });
Copy link
Member

Choose a reason for hiding this comment

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

This PR will likely follow #5676, I'm not sure that we'd need to trigger timeupdate with the changes in #5676.

test/unit/reset-ui.test.js Show resolved Hide resolved
test/unit/reset-ui.test.js Outdated Show resolved Hide resolved
test/unit/reset-ui.test.js Outdated Show resolved Hide resolved
test/unit/reset-ui.test.js Outdated Show resolved Hide resolved
@gkatsev gkatsev added the patch This PR can be added to a patch release. label Dec 18, 2018
@gkatsev
Copy link
Member

gkatsev commented Dec 19, 2018

I guess the duration automatically gets reset to NaN as part of the reset process right now?

Also, can resetControlBarUI be made "private" by appending the _ suffix? https://github.com/videojs/video.js/pull/5684/files#r241475268

However, this is more or less good to go.

@reeckset
Copy link
Contributor Author

@gkatsev yes it does. I just added the suffix. Ready to go!

Copy link
Member

@gkatsev gkatsev left a 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!

@xRuiAlves
Copy link

Thanks @gkatsev ! Any changes we can help in, let us know

@gkatsev
Copy link
Member

gkatsev commented Jan 3, 2019

Looks like there wasn't much conflicts after merging in #5676. I've resolved the conflict via github.

@gkatsev gkatsev added the needs: LGTM Needs one or more additional approvals label Jan 3, 2019
Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

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

Thanks!

@misteroneill misteroneill removed the needs: LGTM Needs one or more additional approvals label Jan 8, 2019
@gkatsev gkatsev merged commit 175f773 into videojs:master Jan 8, 2019
@welcome
Copy link

welcome bot commented Jan 8, 2019

Congrats on merging your first pull request! 🎉🎉🎉

@gkatsev
Copy link
Member

gkatsev commented Jan 8, 2019

Thanks all!

@matt-snider
Copy link

@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 reset() was called, it will remain there indefinitely. I saw that there is also #5629 which is open so maybe it's meant to be addressed there?

@amtins amtins mentioned this pull request Feb 26, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch This PR can be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants