Sound Component

I never used sound before.
I have an entity with the script and sound components on.
this is how the component looks, and with this line of code, I am trying to get music to start“music”);
But still, there is no music, whatsoever

I just found that I have to click on the screen in order for music to start playing
This is really weird, is it possible to start immediately without user assistance?

Just ran into this same issue today, and unfortunately this is a browser policy, you can read more here.

You can assume that sound will autoplay only if at least one of the following is true:

  • The audio is muted or its volume is set to 0
  • The user has interacted with the site (by clicking, tapping, pressing keys, etc.)
  • If the site has been allowlisted; this may happen either automatically if the browser determines that the user engages with media frequently, or manually through preferences or other user interface features
  • If the autoplay Permissions Policy is used to grant autoplay support to an <iframe> and its document.

This definitely feels more complex than it needs to be. But as the MDN Web Docs explains, “From the user’s perspective, a web page or app that spontaneously starts making noise without warning can be jarring, inconvenient, or off-putting. Because of that, browsers generally only allow autoplay to occur successfully under specific circumstances.”

So I guess that sounds fair.


Thank you for the update on the policy @Devortel

1 Like