Wrong startup status of locked variable of audioEngine

I use chrome. When I start the following code:

console.log( `unlocked: ${ BABYLON.Engine.audioEngine.unlocked }` ); // always true

It shows me unlocked = true when actually it’s not. Then I try to play a music but I hear nothing, instead of it there is BJS unlock button appears at the left-top corner. But what’s wrong with the locked variable? How do I know if it unlocked yet or not?

Unlocked is, for historical reasons, true per default. I would use the onAudioLockedObservable (and the onAudioUnlockedObservable) instead, to check when locked and unlocked are triggered:

Test3 | Babylon.js Playground (babylonjs.com)

3 Likes

Thanks for the demo. There’s some error but I get the point.
On line 26, it should be UNlocked instead:

console.log("locked", BABYLON.Engine.audioEngine.unlocked);
1 Like