Understanding html5 audio

Jan 9 2020, 11:48pm

The audio element

First sad thing to note about this element is my Google Chrome 79.0 refuses to play it automatically when page loads, although you've set autoplay attribute to it. It is part of their policy declared at Autoplay Policy Changes.

Your visitors must interact with your page first by, for example a click on the play button, in order to hear it. I think that's acceptable as a sound at page start may subjectively be annoying to some people.

<audio controls autoplay>Sorry, your browser doesn't support HTML5 audio. Upgrade it?</audio>

Second thing is, we don't use neither set the standar src attribute of the audio element nor the <source> child element. We use a line of following javascript to load audio source:

elAud.src = '41364__dobroide__20070923-street-music.wav?t=' + Date.now();

And this is simply for debugging purpose only; because:

Update: oh dear, I've just found out that my Opera 65.0 follows this same rule too.


at our sister site: html5 audio element demo.