All of these examples are in the playground; so, maybe it avoids audio context hell?
I’m now trying to port this very fancy demo (Babylon.js - Web Audio Analyser demo) into VR and hack on it, the problem is I can’t find the full code anywhere, so I had to go into the inspector and start ripping things out, but for the life of me, I cannot figure out how to fire the script from that button that starts the audio engine (and so I’m losing it, lol).
“babylon.js:16 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
e._initializeAudioContext @ babylon.js:16” ← that’s the error message
Somehow, I think I’m supposed to connect the button below to some process that tells engine to start playing the song; and, I have no idea how to do that :<
Yes, I think there’s a cross-browser constraint where you can’t automatically play audio or video on page load - it has to be done on user click or some other event.
That icon I think BJS just overlays to indicate audio engine state. In the past I’ve had to hide it using CSS as I didn’t know any other way.
Word; but how do I get my music to play? I can’t figure out how to get it to play… and I don’t see in the demo where I’m taking this from, how the developer got the music to start when you click that icon?
I think I need to see a full example of audio working not on the playground.
I just tried to implement the simplest playground example of audio from the documentation and I couldn’t get it to play on glitch.com
So, somewhere somebody has a simple example that starts the audio context. e.g. this doesn’t work for me:
window.addEventListener("keydown", function(evt) {
// Press space key to fire
if (evt.keyCode === 32) {
music.play();
BABYLON.Engine.audioEngine.audioContext?.resume();
}
});
BABYLON.Engine.audioEngine.setGlobalVolume(1);