0

I know this question may have been asked before, but no good answers were found while I was searching.

I have a website where I want to add a YouTube video. The goal is to have an autoplaying video with sound on. A lot of users recommended using the html tag iframe to embed it, which seemed to work perfectly with autoplaying except for the sound.

Does anyone know a better solution to this? Would it be better to just upload the video to the server and use the video tag?

    <iframe
  width="100%"
  height="100%"
  src="https://youtube.com/embed/h4gr8eH7D?autoplay=1&amp;controls=0&amp;showinfo=0&amp;autohide=1&amp;mute=1&amp;playlist=h4gr8eH7D&amp;loop=1"
  allow="autoplay"
></iframe>

Supposedly they updated using autoplay=1 to where it had to have mute=1 which makes autoplay work, but with no sound. I saw somewhere someone had used mute=2 to have the audio working, but that didn't work for me either.

RyanP
  • 43
  • 7

1 Answers1

1

The new versions of Chrome prevent any audio from running on a webpage until the user interacts with the page. You CANNOT auto-play a video in a chrome browser unless it's muted and this also applies to videos which you upload to your server. If you'll make the user interact with your page before playing audio, you'll be able to play it.

See also How to make audio autoplay on chrome.

  • Google’s Chrome browser prevents some videos from automatically playing. The web browser allows videos to autoplay on 1,000 sites where Google has determined that people have the highest likelihood of wanting to play videos with sound. Over time, after Chrome studies the websites that you visit, the browser adapts to allow autoplaying on sites where you frequently played videos with the sound on and disables autoplay on sites where you do not. – Shraddha Jul 20 '20 at 19:17