You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HTMLMediaElement.play() method attempts to begin playback of the media and returns a Promise which is fulfilled when the playback has been successfully started, and which is rejected if playback fails to begin for any reason (such as permission issues or other problems).
It seems that Phaser expects .play() to always succeed as can be seen here: https://github.com/photonstorm/phaser-ce/blob/master/src/sound/Sound.js#L721 and it would be nice to have a way to catch this. If we were able to catch this error we would be able to ask the user to interact with the game rather than failing silently as it does now. Also the game keeps reporting that the sound is playing.
The text was updated successfully, but these errors were encountered:
josalmi
changed the title
Unable to catch sound play errors when using WebAudio
Unable to catch sound play errors when using AudioTag
Aug 27, 2018
Do I have to use the play(...) function and don't care about if it throws an error or not or does someone have an example on how to catch an error in js ?
I think this way wa have to catch the errors of all the function in the framework
This Issue is about a bug in the API:
Sound can only be played as a response to user interaction like click event and if you fail to do so browsers will throw errors at you. Quoting from https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
It seems that Phaser expects .play() to always succeed as can be seen here: https://github.com/photonstorm/phaser-ce/blob/master/src/sound/Sound.js#L721 and it would be nice to have a way to catch this. If we were able to catch this error we would be able to ask the user to interact with the game rather than failing silently as it does now. Also the game keeps reporting that the sound is playing.
The text was updated successfully, but these errors were encountered: