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

Add touchstart to enable mobile audio when swiping too #808

Merged
merged 1 commit into from
Oct 6, 2017

Conversation

markknol
Copy link
Contributor

On iOS, if you swipe, for some reason touchend doesn't get triggered. We're building a WebGL game where you needed to perform a swipe movement and sound was only enabled when you actually tapped. Using touchstart seems to fix it. I think it is safe to keep two listeners.

When is the next release planned?

On iOS, if you swipe, for some reason `touchend` doesn't get triggered. We have a game where you needed to swipe and sound was only enabled when you actually tapped. Using `touchstart` seems to fix it. I think it is safe to keep two listeners.
@goldfire goldfire merged commit aabf881 into goldfire:master Oct 6, 2017
@markknol markknol deleted the patch-1 branch October 6, 2017 18:59
@goldfire
Copy link
Owner

goldfire commented Oct 6, 2017

Thanks! Going to try and get 2.0.5 out today, wanting to get a few more issues fixed in it.

@themoonrat
Copy link
Contributor

I seem to remember that i was ios 9 that broke all this originally. Everyone used touch start, ios 9 came out and required touchend instead.

Clearly touchstart works again now, but is that a short term fix? I seem to remember one of the developers for safari saying it made sense to only unlock on touch end because otherwise, and thinking in terms of horrible adds wanting to play sound, you'd pick up scrolling down a webpage on touchstart when actually a tap with touchend is closer to the meaning of the interaction the developers wanted

@goldfire
Copy link
Owner

goldfire commented Oct 6, 2017

Hmm, that is a good point. Do you know if something like mouseup fires at the end of the swipe?

@goldfire
Copy link
Owner

goldfire commented Oct 6, 2017

Also, I just did some more testing and the touchend event seems to be firing on swipe as long as the swipe ends on the same element that it started on. Is that the behavior that you are seeing?

@themoonrat
Copy link
Contributor

mouse wise, anything other than 'click' i've had issues with at one stage or another.

The touchend event thing... I'm not sure, actually. Not at work to get the devices out to test. What I did was make my opening screen require a successful touchend, just like Howler does. Then, if they tried to swipe, well, they're not getting in until they follow the clear instruction to tap!

@goldfire
Copy link
Owner

goldfire commented Oct 6, 2017

Okay, so I put together this fiddle and tested on an iPhone and the touchend fires at the end of the swipe (at least in iOS 11, haven't tried earlier versions). Is this different from what @markknol was referring to?

https://jsfiddle.net/5Leq0ak3/

I'm going to pull this out for now and get 2.0.5 released, but will put it back in once we've nailed down the correct behavior (sorry about the premature merge).

goldfire added a commit that referenced this pull request Oct 6, 2017
@markknol
Copy link
Contributor Author

markknol commented Oct 6, 2017

Ok, but did you test it with sound and did it enable?

@goldfire
Copy link
Owner

goldfire commented Oct 6, 2017

@markknol Good point! I just modified the fiddle to try unlocking the audio and while the touchend event does fire, it doesn't seem to work as you stated. I've added the touchstart back in and it seems to work. I'll go ahead and get this included in 2.0.5 after all.

@markknol
Copy link
Contributor Author

markknol commented Oct 6, 2017

Thanks! This was exactly my experience too 👍

bhaskarp-vg pushed a commit to ValueGlobal/howler.js that referenced this pull request Feb 7, 2018
ringcrl pushed a commit to ringcrl/howler.js that referenced this pull request Apr 21, 2019
Add touchstart to enable mobile audio when swiping too
ringcrl pushed a commit to ringcrl/howler.js that referenced this pull request Apr 21, 2019
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.

3 participants