0
(HTML5) I can't put in an audio autoplay for my website that i code in sublime 3, can someone please help ? 😊
<!DOCTYPE html> <html> <head> <meta chartset="UTF-8"> <title>audio</title> </head> <body> <audio> <iframe src="file:///C:/Users/User/Desktop/Siteweb_JuliaMoi/accueil/audio.html" autoplay/> </audio> </body> </html> code isn't working
7 Réponses
+ 2
add
<script>onload = () => { document.addEventListener("click", () =>{ document.querySelector("audio").play() })} </script>
and click the screen once.
+ 2
its a policy that audio need user interaction to play. so autoplay is no longer possible atm.
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
0
Please clarify your questions.
Are you having problem of
1. Cannot add audio to webpage?
2. Cannot set the added audio to autoplay?
3. The audio works on localfile but not after you upload to a web host?
0
I can't add the audio to the web page. I'm not sure whether i'm not coding right or if the file in mp3 isn't readable
0
If you are doing it locally. There is a path issue.
For file in the same root directory, you can use relative path.
Let me create a video for you, just a minute.
0
Thank you but it's still not working, here is my code:
<!DOCTYPE html>
<html>
<head>
<meta chartset="UTF-8">
<title>audio</title>
</head>
<body>
<audio>
<source src="audio.mp3" autoplay>
</audio>
</body>
</html>