Sound issues on iOS

So, what’s up with the Babylon’s sound system and mobile devices (currently testing iOS)?
Even the simplest setup does not work:

this.sndAmbient = new BABYLON.Sound("Ambient", "ocean.mp3", this.babylonScene, null, {
                loop: true,
                autoplay: false,
                volume: .2,
                spatialSound: true,
                maxDistance: 30
            });

Then, somewhere below:

window.addEventListener("click", ()=> {
      this.sndAmbient.play();
});

Works on desktop, does’t on iPhone. No errors on console.

Am I missing something?
Are there some good practices to initiate/enable sound on mobiles?

Cheers

iphone force you to run the sounds from a user interaction but it seems that you are already doing it

does the samples on the PG works?
https://www.babylonjs-playground.com/#DXAEUY#0

Same as in my project: works on a desktop (Chrome), doesn’t on iPhone (I get the “no sound” icon popping up).

iOS 13.1.3

And what if you click the icon? Still no sound?

Let me invoke @RaananW for help

No, if you click it - it just disappears.

Hey max,

Disappears? Any exception thrown or something we can work with? I am searching in the meantime. I know they changed the permission management in iOS, just need to see if they did something with audio as well

Hi Raanan,
No, no errors or exceptions thrown - I use remote debugging all the time!

…and to throw another curveball: scene.audioEnabled returns bloody true!

Can you try this -

https://www.babylonjs-playground.com/#DXAEUY#24

click on the screen, press the button. Does this play the sound?

Starts like this:


As soon as you click on the screen, you get this:

Works fine on Android/Chrome btw, just tested on Galaxy S7.
WTF, Apple?? They keep disabling features on the browser (first accelerometer, now sound!) to keep raking in revenue from their crappy appstore. Greedy c*nts!

1 Like

This is the same on latest chrome canary on Android, but when you press the button it disappears and the sounds plays.

If, when pressing the button, the sound doesn’t play, I would say it is something fundamentally wrong with iOS safari. This is an HTML5 standard, I doubt they removed it. Thou i can’t find any information to approve or deny that