I’m currently facing an issue with the audio. At the moment, I need to click on the small mute/unmute button in the top left corner of the scene to mute/unmute the audio of my game.
The issue is that I would my audio to play when it is ready without having to enable/disable the button. At the moment, I’m able to remove the audio button via this line of code
Engine.audioEngine.useCustomUnlockedButton = true;
but then, no sound is playing even if I do
What line of code should I add to make that possible?
There’s no line that makes that possible, as every browser requires an user interaction to start audio Which is a good thing if you think about it, imagine if ads could just start blaring audio at full volume
Yes I understand that …
However, can we hide the button and enable the audio when the player click on the screen?
Ooooh, my bad, I understood you were asking something different I dug a bit more in the audio engine, and I could get it to play on click by calling
unlock on pointer down: Sounds not ready to play | Babylon.js Playground (babylonjs.com) (it looks like that doesn’t work if the unlock isn’t inside a user interaction, which makes sense)
Thanks for the quick reply! However, the audio button is still there and I still have to click on it to enable the audio…
Huh, weird, which browser are you using? I tested on Edge, Chrome and Firefox but the behavior can be browser dependent
I tested on Chrome and Edge.
Hey @Rangerz132 just checking in if you’re still having this issue?
Hi! I find out that this issue was only occurring when I was reloading the page which is strange but it’s ok! Thanks