Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio AutoPlay on HTML Website not working

I tried to make a fan-website for a artist so I wanted to have start page music which automatically plays. But, when I open the start page, my audio file doesn't play.

This is my code:

<audio controls autoplay loop>
   <source src="https://s3.amazonaws.com/Syntaxxx/bigger-picture.mp3" type="audio/mpeg" />
   <p>If you can read this, your browser does not support the audio element.</p>
</audio>

What I need to do to make this start playing automatically?

like image 872
GSV Avatar asked Sep 16 '25 11:09

GSV


2 Answers

autoplay is a html standard. It's up to then browser to support it or not. I suspect you used Chrome, like so many others, and were surprised it didn't work. https://www.w3schools.com/tags/att_audio_autoplay.asp If you test this code, like I did, in Firefox 63, it will work fine. Google decided to break the web standard in May 2018: https://bugs.chromium.org/p/chromium/issues/detail?id=840866#c103

like image 190
CaptainCrunch Avatar answered Sep 18 '25 10:09

CaptainCrunch


As of 2020, browser defaults mean this won't work in Firefox (all platforms) and Chrome (Android included, but not Mac it seems).

like image 29
tog22 Avatar answered Sep 18 '25 09:09

tog22