The Media Engagement Index (MEI) measures an individual’s propensity to consume media on a site. Chrome’s approach is a ratio of visits to significant media playback events per origin:
Consumption of the media (audio/video) must be greater than seven seconds.
Audio must be present and unmuted.
The tab with the video is active.
Size of the video (in px) must be greater than 200x140.
From that, Chrome calculates a media engagement score, which is highest on sites where media is played on a regular basis. When it is high enough, media is allowed to autoplay on desktop only.
I know that sound requires user interaction. Same in all browsers. I showed in my above link how to enable it after interaction.
I’m just saying that Babylon keeping things muted even after user interaction is the wrong thing for Babylon to do. Most people don’t want that. Most people want their audio to play as soon as interaction happens (without requiring the end user to also press an un-mute button).
I just joined a Babylon project, and the default audio behavior was bugging everyone on the team. Not a single person thought having the app muted (even after user interaction) was a good default.
@trusktr
Please stop necro’ing multiple threads on the same topic
Due to the backwards compatibility promise of BabylonJs,
It’s unlikely that the default behavior will be changed, there are already tons of projects expecting it to behave as it currently does, all of which should be able to upgrade to a newer version of BabylonJs seamlessly. Changing the default behavior would not allow this.
However, I decided to made you an example of how to properly handle this situation here:
I will add it to the docs aswell.
Please confirm if it works in safari, it’s dangerous to assume things when it comes to apple tech
Edit
Listening to onAudioUnlockedObservable was unnecessary. updated pg.
So the problem is that it requires one full user interaction to unlock the audio after the website is initially loaded, this can cause some issues when/if the first click is also wanting to play audio.
That PG works for me though when i click the right box with the actionManager attached, only because that click unlocks the audio and the audio is autoplay: true
Also keep in mind that audio unlocking is asynchronous.
Can you describe exactly what you hope to achieve?, preferably a PG with comments.
Is it continuous looping background music or a short audio clip that plays when clicking a mesh, etc
I did discover an issue when trying to use BABYLON.Engine.audioEngine.unlocked
Any idea why it is true by default?
Sometimes it will return true when reading it for the first time, even though the audio is not unlocked, I experienced the entire audioEngine siezing up a couple times and stop responding.
Do you think we can invert the behavior, set it to false by default and update to true if the browser does not require audio to be unlocked?
Context: “siezing up”.
No audio with autoplay.
We only want to call the unlock() function once.
If we change the AudioEngine.unlocked flag to be initialized to false instead of true, it makes the mute button show up immediately whether a sound tries to play or not. Currently the mute button doesn’t show until a sound tries to play.
reports -1 if executed before any Sound has been created.
This implies AudioEngine state is coupled to Web Audio. Instead, AudioEngine should be an abstraction that is 100% a level above Web Audio, and should map its state to Web Audio once Web Audio is loaded, otherwise this internal behavior is leaking to the outside in a way that makes user code difficult to create, and buggy.
When a setter is given a value, the getter should always return the last value that was set.