How to have background music without pressing button in react-native?

I keep finding tutorials on background music for react-native but they all require a button. I try using npm background music but it doesn’t work.

Are you experiencing this issue in a web browser, or on a mobile device? Most modern web browsers prevent auto-play media (including background music) until/unless the user interacts with the page first. If you’re experiencing this on a mobile device, then it’s likely the WebView in which your app runs also has the same restriction.

Have you tried programmatically pressing the button (i.e., triggering a “click” event on it) to start the background music? That might not work (browsers can tell the difference between a programmatic click and one that actually came from the physical device), but it’s worth a try.

Another option would be to “force” the user to interact with the page in a way that seems natural to the application, and have that interaction start the background music.