Autoplay audio problem

I have this code and it works well…

var music = new BABYLON.Sound(“tv”, “textures/tvmusic.mp3”, scene, function () {
}, { loop: true, autoplay: true });

but when I add this…


give me this error…

AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

Yes this is a constraint enforced by browsers. The code that attach the music to the mesh mut be inside a user clickable content (like a button or a link)

1 Like