0

I am trying to make web with audio on backgroud using Youtube audio
I found this code

<body>
        <div data-video="Iq1OzH9adIc"
                data-autoplay="1"
                data-loop="1"
                id="youtube-audio">
         </div>
</body>
<script src="https://www.youtube.com/iframe_api"></script>
<script src="https://cdn.rawgit.com/labnol/files/master/yt.js"></script>

But audio will play when button clicked
any suggest how to make it auto play ??

fhdyt
  • 7
  • 4

1 Answers1

0

In order to autoplay the youtube in HTML, add autoplay=1 and mute=1 in the src parameter.

FYI. Without mute parameter to 1, the youtube videos will not be playing even if autoplay is enabled.

<!DOCTYPE html>
<html>
<body>

<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&mute=1">
</iframe>

</body>
</html>
Ejilarasan J
  • 310
  • 1
  • 3
  • 11