Youtube embedded video autoplay

2019-06-14 10:47发布

问题:

...not working. Any ideas why?

<iframe width="560" height="315" src="https://www.youtube.com/embed/nwe76N7J0EI?rel=0&amp;controls=0&amp;showinfo=0&amp;start=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

this is a latest code youtube provides

回答1:

It's the browser blocking autoplay(with sound) by default.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

It was finally implemented a few months ago. You can still use autoplay, but the video will need to be muted.

Notice the added mute=1 in the embed below. It will autoplay, but it breaks if you remove it.

<iframe width="560" height="315" src="https://www.youtube.com/embed/nwe76N7J0EI?rel=0&autoplay=1&mute=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>


回答2:

I added mute=2 and the video autoplayed with sound.