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!

2 Likes

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

Any updates? OMG it’s Q4 2021

@RaananW do you know what’s the state of sound in Safari now?

TBH - I have no idea. I don’t have an iphone to test this with. But I would trust apple to keep that issue open for a few more years.

Joke aside, any iPhone users who can confirm that the issue still exists?

I cannot hear any sounds from https://www.babylonjs-playground.com/#DXAEUY#24 on iPhone with Chrome or Safari. Sometimes I see sound icon, that’s all :frowning:

1 Like

Can you enable the sound by pressing the sound icon? Or is it just avoiding enabling sounds altogether?

I see sound icon not every time. When clicking on it nothing happens (no sound).
With this example from docs - https://playground.babylonjs.com/#PTV7W#1 Chrome works as supposed to.
And, finally, with this example I had success with Safari too.
(tested with iPhone 8).

I think the issue is with the show/hide logic of the permission interaction button, just tested on edge iPad and got the interaction button and sound to show and play

Works all good on my iphone with all demo PG, not sure how to repro but I remember once I spent a day figuring I was on silent mode and on Safari no ways like other apps to have sounds in this mode.

2 Likes