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

HTML5 audio doesn't work in safari (on latest MacOS) #3309

Closed
alexandernst opened this issue Mar 3, 2018 · 10 comments
Closed

HTML5 audio doesn't work in safari (on latest MacOS) #3309

alexandernst opened this issue Mar 3, 2018 · 10 comments

Comments

@alexandernst
Copy link

alexandernst commented Mar 3, 2018

For example http://labs.phaser.io/view.html?src=src\audio\HTML5%20Audio\AudioSprite.js

@alexandernst alexandernst changed the title HTML5 audio doesn't work in safari HTML5 audio doesn't work in safari (on latest MacOS) Mar 3, 2018
samme added a commit to samme/phaser that referenced this issue Mar 3, 2018
@photonstorm
Copy link
Collaborator

With the update merged in I'd love to know what errors you now get @alexandernst

@alexandernst
Copy link
Author

NotAllowedError (DOM Exception 35): The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.  — HTML5AudioSound.js:346
playCatchPromise — HTML5AudioSound.js:340
pickAndPlayAudioTag — HTML5AudioSound.js:256
play — HTML5AudioSound.js:113
playAudioSprite — BaseSoundManager.js:258
(función anónima) — AudioSprite.js:67
emit — index.js:182
processDownEvents — InputPlugin.js:506
update — InputPlugin.js:1510
emit — index.js:203
step — Systems.js:278
update — SceneManager.js:478
step — Game.js:363
step
step — TimeStep.js:519
step
step — RequestAnimationFrame.js:102

Note that I was never asked about allowing (or denying) anything.

@sftsk
Copy link
Contributor

sftsk commented Mar 10, 2018

It seems like the same is happening on iOS when switching scenes and trying to play audio. The first audio you play works, but the next one will fail (silently) with this error.

@sftsk
Copy link
Contributor

sftsk commented Apr 11, 2018

@photonstorm any progress looking into this?

@photonstorm
Copy link
Collaborator

Nope. I don't have a Mac to test on, so it will need someone else to jump in. Although I'm curious why it's even trying to use HTML5Audio at all, it should be using WebAudio.

@sftsk
Copy link
Contributor

sftsk commented Apr 12, 2018

Alright, just removed

audio: {
    disableWebAudio: true
  },

from the game config and now audio works just fine on iOS/ Safari on macOS.
Not sure why I thought HTML5 audio would be the way to go but this might happen to others as well. Perhaps tell in the examples it's advised to use Web Audio.

Cheers!

@photonstorm
Copy link
Collaborator

I’ll keep this open because old school Audio should still work on Safari, but you absolutely don’t want to use it unless forced to.

@pavle-goloskokovic
Copy link
Contributor

@photonstorm I have a fix for this but can't test it since all HTML5 Audio examples are broken with following error:

Uncaught RangeError: Maximum call stack size exceeded
    at HTML5AudioSound.set [as mute] (HTML5AudioSound.js:627)
    at HTML5AudioSound.setMute (HTML5AudioSound.js:655)
    at HTML5AudioSound.set [as mute] (HTML5AudioSound.js:636)
    at HTML5AudioSound.setMute (HTML5AudioSound.js:655)
    at HTML5AudioSound.set [as mute] (HTML5AudioSound.js:636)
    at HTML5AudioSound.setMute (HTML5AudioSound.js:655)
    at HTML5AudioSound.set [as mute] (HTML5AudioSound.js:636)
    at HTML5AudioSound.setMute (HTML5AudioSound.js:655)
    at HTML5AudioSound.set [as mute] (HTML5AudioSound.js:636)
    at HTML5AudioSound.setMute (HTML5AudioSound.js:655)

@photonstorm
Copy link
Collaborator

Yeah :( I fixed it earlier today though, master is safe now.

@pavle-goloskokovic
Copy link
Contributor

This is now fixed and can be tested with this example: http://labs.phaser.io/view.html?src=src\audio\HTML5%20Audio\play%20audio%20from%20child%20scene.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants