Reputation: 21
<!DOCTYPE html>
<html>
<body>
<audio id="myAudio">
<source src="punch-high1.mp3" type="audio/mpeg">
</audio>
<script>
var x = document.getElementById("myAudio");
x.loop = true;
x.autoplay = true;
x.load();
</script>
</body>
</html>
This is the code I'm currently using to test out Autoplay with the audio tags. But it's not working, I have tested it with the horse.mp3 from w3schools and made it match this code EXACTLY how it is, but this code still doesn't work while the code from w3schools that I modified does. And I have tried using autoplay within the first audio tag but it doesn't work.
Upvotes: 2
Views: 129
Reputation: 1273
After Chrome 66 update, you need to manually change your Chrome settings so that the autoplay works.
Steps to follow:
chrome://flags/#autoplay-policy
in the URLP.S.: You do not require x.load()
statement in your code.
Upvotes: 1