0

Why is my audio not playing?

I want to make my audio play, like a magic audio. It should be invisible and play automatically https://code.sololearn.com/Wk2mYHAPJN1S/?ref=app

1st Oct 2021, 12:28 PM
Rishi
Rishi - avatar
5 Réponses
+ 2
Add control attribute in Audio tag <audio controls autoplay loop> <source src="https://www.computerhope.com/jargon/m/example.mp3" type="audio/mpeg">
1st Oct 2021, 12:31 PM
SAN
SAN - avatar
+ 2
SAN no I want to make it invisible. but even if i add, it's not auto-playing
1st Oct 2021, 12:32 PM
Rishi
Rishi - avatar
+ 1
Try this window.onclick=()=>{ document.getElementById('audio').play(); }
1st Oct 2021, 12:35 PM
SAN
SAN - avatar
+ 1
SAN I don't know CSS and JavaScript, I only know HTML. actually why didn't my code work? because it's correct and should work right?
1st Oct 2021, 12:36 PM
Rishi
Rishi - avatar
+ 1
Rishi These are some threads discussing similar issue. Maybe one of them was relevant. P.S. I used "autoplay not working" search term under "Most Popular" scope. https://www.sololearn.com/Discuss/2330298/?ref=app https://www.sololearn.com/Discuss/2059721/?ref=app https://www.sololearn.com/Discuss/998457/?ref=app https://www.sololearn.com/Discuss/1191642/?ref=app
1st Oct 2021, 1:16 PM
Ipang