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

feat: allow progress controls to be disabled #4649

Merged
merged 6 commits into from
Oct 31, 2017

Conversation

brandonocasey
Copy link
Contributor

Description

Sometimes you do not want the user to be able to use the progress controls, such as during an ad. It would be quite difficult to do this outside of video.js due to the complexity of it. I think that we should allow this within video.js.

Specific Changes proposed

Add functions to disable/enable progress controls

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
    • Unit Tests updated or fixed

@thijstriemstra
Copy link
Contributor

It would be quite difficult to do this outside of video.js due to the complexity of it.

Here's what I used:

if (this.player.options_.controls) {
    // progress control isn't used by this plugin
    this.player.controlBar.progressControl.hide();
}

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2017

Hm... I'm not sure we want this. Disabling built-ins like this seems really weird to me. Since I can see cases where you'd want the progress control but just disable seeking but right now this disables it completely, if I understand it correctly.
One thing that I was thinking off middleware is the ability to cancel a chain, this is something that's currently missing and I think might fit better for the specific usecase.

@brandonocasey
Copy link
Contributor Author

Well the real issue here is @gkatsev there isn't a good way to disable dragging on the progress bar when you want to. Disabling clicks is easy enough. All that this PR does is disable interacting with the progress bar. It is still there and works as intended, you just cant use it to seek.

@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2017

Yeah, maybe this isn't that bad. We should either keep listening to mousemove or we should hide the mouse time display when disabled. Also, we probably want to change the cursor to regular when the control bar is disabled.

Also, probably should just be called disable and enable.

@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2017

Maybe just hiding the mouse time display is best as another indicator that this is a "read-only" control would be better.

@brandonocasey
Copy link
Contributor Author

All good ideas, I will implement them when I get some time.

@@ -8,6 +8,10 @@
min-width: 4em;
}

.video-js .vjs-progress-control.disabled {
cursor: default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't really want a pointer when its disabled

@@ -36,7 +40,7 @@

// This increases the size of the progress holder so there is an increased
// hit area for clicks/touches.
.video-js .vjs-progress-control:hover .vjs-progress-holder {
.video-js .vjs-progress-control:hover .vjs-progress-holder.enabled {
font-size: 1.666666666666666666em;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we only want to increase the size on hover when enabled

this.off(doc, 'mouseup', this.handleMouseUp);
this.off(doc, 'touchmove', this.handleMouseMove);
this.off(doc, 'touchend', this.handleMouseUp);
this.removeAttribute('tabindex');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't allow tabbing to the slider when it is disabled

Copy link
Member

Choose a reason for hiding this comment

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

Good call.

@@ -36,7 +40,7 @@

// This increases the size of the progress holder so there is an increased
// hit area for clicks/touches.
.video-js .vjs-progress-control:hover .vjs-progress-holder {
.video-js .vjs-progress-control:hover .vjs-progress-holder.enabled {
Copy link
Member

Choose a reason for hiding this comment

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

do we need an enabled class? Can that just be the default and also have a disabled 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.

sure we can do that

}

this.removeClass('disabled');
this.addClass('enabled');
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need an enabled class, like mentioned earlier

this.off(doc, 'mouseup', this.handleMouseUp);
this.off(doc, 'touchmove', this.handleMouseMove);
this.off(doc, 'touchend', this.handleMouseUp);
this.removeAttribute('tabindex');
Copy link
Member

Choose a reason for hiding this comment

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

Good call.

@@ -40,6 +44,10 @@
font-size: 1.666666666666666666em;
}

.video-js .vjs-progress-control:hover .vjs-progress-holder.disabled {
Copy link
Member

@gkatsev gkatsev Oct 26, 2017

Choose a reason for hiding this comment

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

I don't think this block is necessary and it causes the time display not to look right
screen shot 2017-10-26 at 11 25 00
screen shot 2017-10-26 at 11 31 45
First is the "broken" one, second is the "correct" one.

Though, now that I think about it, this is probably on purpose so that the progress holder/seek handle isn't as large?

@brandonocasey brandonocasey added the needs: LGTM Needs one or more additional approvals label Oct 26, 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.

LGTM

@gkatsev gkatsev added confirmed and removed needs: LGTM Needs one or more additional approvals labels Oct 31, 2017
@gkatsev gkatsev merged commit a3c254e into master Oct 31, 2017
@gkatsev gkatsev deleted the feat/disable-progress-controls branch October 31, 2017 18:50
@nicu-chiciuc
Copy link

Didn't want to open a new issue since this one seems to be quite close. Basically based on Slider.js:78 I should be able to call player.controlBar.progressControl.seekBar.disable() and the user should not be able to seek anywhere.

Although the method is called and all the events are set off, the events still persist.

I'm currently trying to adapt danielcebrian/rangeslider-videojs to my needs so it will take some time to come up with some jsfiddle that shows this in action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants