html audio loop and autoplay | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

html audio loop and autoplay

I know this function is limited but what is the best basic workaround for cross-browser <audio> loop and autoplay hidden on a site?

17th Mar 2020, 6:10 PM
Olivia Mikayla
Olivia Mikayla - avatar
2 Answers
+ 3
Hi Olivia :) Try this: <audio controls> <source src="audiofile.mp3" type="audio/mpeg"> <source src="audiofile.ogg" type="audio/ogg"> <!-- fallback for non supporting browsers goes here --> <p>Your browser does not support HTML5 audio, but you can still <a href="audiofile.mp3">download the music</a>.</p> </audio> also if you dont include autoplay or loop in the <audio> tag it wont play/repeat..
17th Mar 2020, 8:12 PM
behindThePixels
behindThePixels - avatar
+ 2
17th Mar 2020, 9:23 PM
Olivia Mikayla
Olivia Mikayla - avatar