YouTube Autoplay Issue

梦想的初衷 提交于 2020-02-07 02:38:07

问题


I am trying to get an embedded YouTube video to autoplay. I have set the ?autoplay=1 in the parameter but this seems to be deprecated. I have not been able to find any documentation on it though.

How can I get autoplay to work on videos?

<iframe class="iframe-vid" width="560" height="315" src="https://www.youtube.com/embed/Bey4XXJAqS8?autoplay=1&enablejsapi=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

回答1:


If you don't mind that the video autoplays muted, you can add the following parameter in the YouTube URL:

&rel=0&mute=1

Here is the iframe with autoplay enabled and muted1

<iframe class="iframe-vid" width="560" height="315" src="https://www.youtube.com/embed/Bey4XXJAqS8?autoplay=1&enablejsapi=1&rel=0&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
  • Test made in Google Chrome Version 72.0.3626.119 (Build oficial) (32 bits)

1 I really don't know why the "mute" option must be set in the URL (and only in Google Chrome), because in Firefox and Edge the video autoplays without adding the mute parameter.



来源:https://stackoverflow.com/questions/54889615/youtube-autoplay-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!