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

Enable listening for touch events above the player #992

Merged
merged 10 commits into from
Feb 7, 2014

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Feb 6, 2014

This fixes #980.
This makes each component report user activity. The MediaTechController and Player need to disable this. MediaTechController reports user activity manually as it also handles hiding and showing of the control bar.
The tap test should only focus on taps.

Make components listen to touch events themselves.
Components can have a "listenToTouchMove" property that would report
user activity on touch moves.
Currently, the only problem left is that the MediaTechController emits
tap events to show/hide the controlbar but that causes the control bar
to not be hidden via a tap.
Make media tech controller only hide control bar.
disableUserActivity on MediaTechController and Player.
MediaTechController does it manually.

// Turn on component tap events
this.emitTapEvents();
//this.emitTapEvents();
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need this anymore. Forgot to just delete it.
Do we also want to keep emitTapEvents around since it's not used anywhere else?

Copy link
Member

Choose a reason for hiding this comment

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

Well, it looks like you moved the tap logic to the new touchend event at line 100, but tap works a little differently than just checking for any movement, it also checks if the touch took longer than 250ms (touch and hold). I think we might still want to use the tap event for manually toggling controls specifically.

Copy link
Member Author

Choose a reason for hiding this comment

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

So basically not bother with listening to a touchend above and let the tap events stuff handle toggling of the controls?

Copy link
Member

Choose a reason for hiding this comment

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

There's basically two parts to the media tech touch listeners:

  1. Reporting user activity when the controls are showing, so they keep showing
  2. Toggling the controls on/off when a tap happens

I think we can handle 2 with the tap event, but we still need 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think tap event will cover 2 and reporting activity on touchmove above would cover 1.

@@ -15,6 +15,7 @@ vjs.MediaTechController = vjs.Component.extend({
vjs.Component.call(this, player, options, ready);

this.initControlsListeners();
this.disableUserActivity();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of enabling then immediately disabling, we could potentially pass an option value through to the component init that tells it to not enable in the first place

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense.
Ideas for the option name?
And would I just add it to the options object that Component is called with?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe 'reportUserActivity':false ?
Yeah, add it to the same options.

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense. Doing it now.

@gkatsev
Copy link
Member Author

gkatsev commented Feb 6, 2014

Updated the tap events and touch move user activity.
I think this works even better than it used to now. Previously, if you kept pressing the play/pause button, at some point, the control bar would just hide immediately after you press it, now, it seems to always wait the timeout period before hiding.

this.on('touchcancel', preventBubble);
this.on('touchend', preventBubble);
this.on('touchmove', function(event) {
this.player().reportUserActivity();
Copy link
Member Author

Choose a reason for hiding this comment

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

oops, forgot to make this only report activity if userWasActive.

@gkatsev
Copy link
Member Author

gkatsev commented Feb 6, 2014

Updated the options.

@@ -65,6 +65,10 @@ vjs.Component = vjs.CoreObject.extend({
this.ready(ready);
// Don't want to trigger ready here or it will before init is actually
// finished for all children that run this constructor

if (options.reportUserActivity) {
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 want enableUserActivity to be the default for components, I think we want this to be if (options.reportUserActivity !== false)

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. Done.

@heff heff merged commit 28a4d29 into videojs:master Feb 7, 2014
@gkatsev gkatsev deleted the touchevents branch February 7, 2014 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cant listen to touch events over the video element.
3 participants