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

Fire a new 'playerror' event when unable to play #692

Closed
implicitdef opened this issue Jan 17, 2017 · 2 comments
Closed

Fire a new 'playerror' event when unable to play #692

implicitdef opened this issue Jan 17, 2017 · 2 comments

Comments

@implicitdef
Copy link

When calling myHowlerObject.play(), the underlying call made to node.play() (https://github.com/goldfire/howler.js/blob/master/src/howler.core.js#L740) may fail under specific conditions.
My issue is that this failure is not detectable in any way by my code. Wrapping myHowlerObject.play() in a try/catch does not work, because the actual node.play() is probably called asynchronously. I've tried window.onerror too, without success.

Suggestion : wrap the node.play() in a try/catch in howler's code, and fire a new specific event like playerror if it fails, similar to the existing loaderror.


My use case :
I'm trying to play a sound immediatly when the user arrives on a page (not triggedred by a user gesture). This is restricted on some mobile browsers, making the node.play() call fail. I would still like to have that autoplay if possible and be able to detect when it was blocked, and it that case display something else in the UI to onboard the user and invite him to play the sound. See discussion #609

@kane-mason
Copy link

I have created a fix that is working for me. You can view pull request here:

#721

@goldfire
Copy link
Owner

Closing due to inactivity. If this is still an issue, reply with more info and I'll reopen.

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

No branches or pull requests

3 participants