1

I'm wanting a video to play automatically once it loads on a page. The video has no sound so shouldn't annoy the user too much.

The official YouTube answer for this query is to add &autoplay=1immediately after the video ID, and while that works in this CodePen test, it isn't working on my actual website page.

Elsewhere on Stack Overflow I've seen someone suggest that replacing the & with ? would work, however, doesn't work for me. (It doesn't break the video, it just still doesn't autoplay).

My embedded YouTube video

<div class="background-video" style="background-color: #ebebeb; height: 655px;">

     <iframe width="100%" height="655" src="https://www.youtube.com/embed/bdw7V0vzQCs?&autoplay=1&rel=0&controls=0&showinfo=0" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>

</div>

The site is built on Wordpress and is currently hosted locally on a MAMP server.

Evo
  • 123
  • 1
  • 13
Sam Johnson
  • 672
  • 7
  • 22

2 Answers2

1

You should put ? in front of autoplay only if it's the first attribut added to your youtube url, otherwise you should use &. Like so : your-url.com?autoplay=1 or your-url.com?key=value&autoplay=1 In your case you have ?& that should be replaced by only ?.

Noémie Kerroux
  • 340
  • 3
  • 14
  • I've decided to go a different route to achieve what I wanted, but I'm curious as to why it would work in the CodePen I attached if you're saying it's incorrect. I was under the assumption it'd be a Wordpress/MAMP issue. – Sam Johnson Dec 12 '17 at 11:39
  • @SamJohnson It depends on the browser. It doesn't work on Safari 11.0.1, but it works on Firefox Quantum 57.0.1 and Chrome 63.0. It works fine on them all when put correctly like I said above. – Noémie Kerroux Dec 12 '17 at 13:07
  • I was using FIrefox Quantum and it wasn't working for me. – Sam Johnson Dec 12 '17 at 13:16
  • Have you tried with the same embed Youtube video ? Maybe the problem comes from there – Noémie Kerroux Dec 12 '17 at 13:20
  • Like I say, I came up with a different solution so no longer need any help with this. But I appreciate your help. – Sam Johnson Dec 12 '17 at 13:22
0

Your code is correct, i check video is auto playing create a new php file and check adding your code.

May be have some problem with site.

Raman
  • 1
  • 1
  • 3