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

Mouse events for unlocking Web Audio #6994

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pavle-goloskokovic
Copy link
Contributor

This PR makes an improvement:

Added mousedown and mouseup event listeners for unlocking Web Audio. Both events occur before existing click event, allowing for earlier audio unlocking on devices that use mouse.

@photonstorm
Copy link
Collaborator

If we add those I don't see the need to keep the click event at all. Can anyone think of one?

@pavle-goloskokovic
Copy link
Contributor Author

If we add those I don't see the need to keep the click event at all. Can anyone think of one?

Technically we don't need mouseup and touchend if mousedown and touchstart work.

But it depends on browser vendors which user gestures they perceive as valid for resuming audio context. And we don't have control over it or insight into specific browser implementations.

click also occurs on mobile, where not all touchstart and touchend are valid user gestures (like when part of a swipe or a scroll).

I would say that we are safe to remove click listener, but would keep it in to cover some potential edge cases, and have audio unlocked as soon as possible.

@photonstorm
Copy link
Collaborator

mouseup and touchend are there because the event may have started outside of the canvas but completes while over it.

@pavle-goloskokovic
Copy link
Contributor Author

Makes sense. I removed click handlers and updated locked condition to only depend on audio context state. Also fixed condition for invoking unlock method.

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.

2 participants