The AudioContext was not allowed to start
Quillraven opened this issue · 2 comments
Hi,
I have again an issue with playing audio in the Browser Link to the game.
According to the browser console:
It seems like calling Music.play()
fails if it is called at the application startup? If I control the player (WASD, SPACE) then e.g. I can here the sound for the jump effect and also the jingle when I get in contact with the finish flag.
But the normal background music of the map is not played.
Can I somehow force a gesture to also play music immediately without an interaction of the user first? Or is there another solution to this issue?
edit: by the way, I use Edge as a browser.
I dont think there is a way to force a gesture. What they recommend is to add a play button at start of the game to be the first interaction .
https://gamedev.stackexchange.com/questions/163365/html5-games-play-failed-because-the-user-didnt-interact-with-the-document-fi
https://stackoverflow.com/questions/64929753/play-failed-because-the-user-didnt-interact-with-the-document-first-issue
https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
Thanks for responding. I actually did a similar solution now. After preloading some resources I show a text to the user "click to continue" and only after that touch event, I go to the real game and from there music playing is working.
Thank you xpenatan :)