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

fix: reset to a play/pause button when seeking after ended #4614

Merged
merged 4 commits into from
Sep 20, 2017

Conversation

brandonocasey
Copy link
Contributor

Description

When seeking backwards after the video has ended, the vjs-ended class will remain on the video until play is pushed. This means the the play button will still show as a replay button, which seems incorrect to me.

Specific Changes proposed

This PR removes vjs-ended on any seeked event on the player and resets the button into a play/pause state depending upon the player state.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

// depending on the current state
this.removeClass('vjs-ended');

if (this.player_.paused()) {
Copy link
Member

Choose a reason for hiding this comment

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

if we're ended, we should already be paused, so, I think we can probably simply this. Maybe we can just call the handlePause handler so we don't duplicate work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about it, but it seemed a bit weird to be calling a function made for being called by events manually. If you don't see a problem with it. I can go ahead and do it though.

Copy link
Member

Choose a reason for hiding this comment

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

probably ok? Can always pull it out into a separate function that both methods can call.

@brandonocasey
Copy link
Contributor Author

@gkatsev updated

@gkatsev gkatsev added the patch This PR can be added to a patch release. label Sep 19, 2017
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.

Code LGTM.
Needs to be tested, though.

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.

Tried it out and looks good to me but I think we should update the conditional.

*/
handleSeeked(event) {
// check to see if the video has ended yet
if (!this.hasClass('vjs-ended')) {
Copy link
Member

Choose a reason for hiding this comment

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

oh, we probably should use this.ended() instead of checking the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I guess that will work, should be this.player_.ended() right?

Copy link
Member

Choose a reason for hiding this comment

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

oops, yes, it's on the player

// remove the ended class
this.removeClass('vjs-ended');

if (this.player_.paused()) {
Copy link
Member

Choose a reason for hiding this comment

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

why would we not be paused when we're ended?

Copy link
Contributor Author

@brandonocasey brandonocasey Sep 20, 2017

Choose a reason for hiding this comment

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

Without this check clicking the button (which causes a play and then a seek to 0) would cause the button to show up as a play button, even when the player is playing.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see.

this.removeClass('vjs-paused');
this.addClass('vjs-playing');

if (!this.hasClass('vjs-playing')) {
Copy link
Member

Choose a reason for hiding this comment

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

why not just keep this as unconditional?

*/
handleEnded(event) {
this.removeClass('vjs-playing');
this.addClass('vjs-ended');

if (!this.hasClass('vjs-ended')) {
Copy link
Member

Choose a reason for hiding this comment

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

why not just keep this as unconditional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved them back to unconditional as this is already a check in addClass.

@@ -83,20 +105,33 @@ class PlayToggle extends Button {
*/
handlePause(event) {
this.removeClass('vjs-playing');
this.addClass('vjs-paused');

if (!this.hasClass('vjs-paused')) {
Copy link
Member

Choose a reason for hiding this comment

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

why not just keep this as unconditional?

@gkatsev gkatsev merged commit 335bcde into master Sep 20, 2017
@gkatsev gkatsev deleted the fix/replay-button-seek branch September 20, 2017 17:45
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.

2 participants