Why does the attribute "autoplay" not start audio?

Asked

Viewed 667 times

0

I am creating a page where I need to play a sound automatically as background in an infinite loop. The problem is that even using the attribute autoplay, audio does not start.

See below my code:

<audio controls autoplay loop>
    <source src="main_sound.mp3" type="audio/mpeg"/>
</audio>

I’m using the browser Chrome 81.0.4044.92 and also tested in Internet Explorer. In both browsers this property is not working because ?

What I can do to automatically play audio using HTML only ?

  • You need to provide a valid URL for src audio. You checked this?

  • Yes. Audio plays if I click the play button, but it does not run automatically with the property autoplay.

  • 2

    Imagine you walk into a website and suddenly there’s the sound of the Black P*rocão playing automatically? Do you understand Pq doesn’t work? Ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha r=SearchResults&s=1|20.1922#412124

  • It didn’t work. I copied the answer code by taking only the attributes width and height and audio still does not start.

  • 2

    It won’t work what to do, Chrome as I think all other browsers have modified their auto-play policy all for a better user experience how to read here: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

  • So how can there be sites where a song or video plays automatically ?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.