自动播放嵌入 YouTube 视频

Mar*_*cus 3 html youtube

我正在尝试将 Youtube 视频嵌入到我的网站中,该视频在页面加载后会自动播放。

我目前正在使用:

<iframe width="560" height="315" src="https://www.youtube.com/embed/V4kXFYRhwL0" 
        frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)

但是,在单击之前视频不会播放。这段代码有什么问题?

网站链接: http: //oxfordcliqr.com/

MrJ*_*ami 11

将其添加到 URL 字符串中:?autoplay=1&mute=1

这会将属性自动播放设置为 1,并将静音设置为 1,以便在页面加载后视频开始播放。

由于政策更改,自动播放视频仅在视频静音时有效。

例子:

<iframe width="560" height="315" src="https://www.youtube.com/embed/V4kXFYRhwL0?autoplay=1&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)