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/ VR360 player's behavior different to standar player on mobile devices #190

Merged
merged 2 commits into from
Nov 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/canvas-player-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,41 @@ class CanvasPlayerControls extends videojs.EventTarget {
}

onMoveEnd(e) {

// We want to have the same behavior in VR360 Player and standar player.
// in touchend we want to know if was a touch click, for a click we show the bar,
// otherwise continue with the mouse logic.
//
// Maximum movement allowed during a touch event to still be considered a tap
// Other popular libs use anywhere from 2 (hammer.js) to 15,
// so 10 seems like a nice, round number.
if (e.type === 'touchend' && this.touchMoveCount_ < 10) {

if (this.player.userActive() === false) {
this.player.userActive(true);
return;
}

this.player.userActive(false);
return;
}

if (!this.shouldTogglePlay) {
return;
}
this.togglePlay();

// We want the same behavior in Desktop for VR360 and standar player
if(e.type == 'mouseup') {
this.togglePlay();
}

}

onMove(e) {
// its hard to tap without a touchmove, if there have been less
// than one, we should still toggle play
if (e.type === 'touchmove' && this.touchMoveCount_ < 1) {
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 increase the limit here?

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 want to check when the movement has finished in the touchend event if it was a "touch for a click" or it was to move the camera in the canvas.

Copy link
Member

Choose a reason for hiding this comment

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

It sounds like this is more or less what the shouldTogglePlay was supposed to do. Set a flag if there was enough touchmoves to exclude it this touch interaction from being a tap. I'd be interested to know if that will work as it'll be a much smaller change and won't require toggling user activity manually.

Copy link
Contributor Author

@marcodeltorob marcodeltorob Nov 8, 2019

Choose a reason for hiding this comment

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

The problem here is we need the change since we want to have the play/pause logic for desktop/mouse and the userActive logic for mobile devices/touch screen when the screen is touched. The current behavior that we have with my changes are:

360°/VR Player iOS/Android
Click/touch - Toggle userActive() - Show and hide control bar.

360°/VR Player Desktop
Click/mouse -- Toggle play/pause since you have the userActive() in mouseover

These ones are in the Standard player:

Standard Player iOS/Android
Click/touch - Toggle userActive() - Show and hide control bar.

** Standard Player Desktop**
Click/mouse -- Toggle play/pause since you have the userActive() in mouseover

this.touchMoveCount_++;
return;
}

// Increase touchMoveCount_ since Android detects 1 - 6 touches when user click normaly
this.touchMoveCount_++;

this.shouldTogglePlay = false;
}

Expand Down