Wix Audio Player issue on initial homepage load

I’m having trouble playing some some audio on my home page when it initially loads. I have an audio player which is hidden and linked to an mp3 file, at the top of the onReady() function I have the line $w(#“audioPlayer1”).play() which works fine in preview but not on the published site when it first loads. However, if I navigate to another page and then come back it plays fine.

Is there something obvious I’m doing wrong? It feels like one of those tiny oversights but it’s driving me up the wall. I’ve tried calling the function on a delay to make sure the audio file is loaded in time, I’ve tried setting the player to collapsed instead of hidden, I’ve tried using different audio file formats but nothing.

You can test it at www.aspirenetwork.co.uk and tell me if I’m wrong and that it works fine for you.

Any tips, hints or help appreciated :clap:

Hi, @Toby_Wegg !!

I believe the reason is that modern browsers impose restrictions on autoplaying music. In the past, many websites would start playing music as soon as they were opened. However, for users who were unaware that a website would automatically play music, this could be quite an inconsiderate and disruptive experience.

To address this, modern browsers generally allow autoplaying music only after the user has performed at least one action to play audio. In other words, if a user manually plays audio on one page of a site, then navigates to another page where autoplay is enabled, the music may start playing automatically. However, the exact behavior can vary slightly depending on the browser.

That being said, the strange behavior you’re experiencing on your site is likely due to these restrictions. If you want to enable autoplaying music, you will need to implement a mechanism where, upon visiting the site, users are prompted with a message like “Would you like to allow autoplaying music?”, along with a button for them to click.

When the button is clicked, playing a short, silent or nearly silent audio clip ( It means that you will write simple code to execute .play() when the button is pressed) will signal to the browser that audio playback has been initiated. At the same time, the prompt informs users and obtains their consent. By following this approach, you can enable autoplaying music in a user-friendly and compliant manner. :wink: :raised_hands: