YouTube自动播放无效 [英] YouTube Autoplay not working

查看:1751
本文介绍了YouTube自动播放无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站有一个播放多个视频的播放器。我一直在调整代码以使用YouTube的iframe API作为播放器。我无法让视频自动播放。以下是相关代码:

My website has a player for multiple videos. I've been adapting the code to use YouTube's iframe API as the player. I can't get the videos to autoplay. Here's the relevant code:

    <body>
          <iframe id="existing-iframe-example"
              width="640" height="360"
              src="https://www.youtube.com/embed/-SFcIUEvNOQ?   autoplay=1&;enablejsapi=1"
              frameborder="0"
              autoplay="1"
              style="border: solid 4px #37474F"
              ></iframe>
        <div id="player"></div>

        <div id="movieButtons" class="movieButtons">
        <button class="movieButton" data-movieAdr="1-VjtC939_Q">Memorial Slide Show</button>

其余的是标准的YouTube iframe API脚本。您可以看到我尝试将Autoplay = 1设置为iframe参数并作为iframe src的一部分。我也尝试将它包含在按钮中的数据中。这些似乎都不起作用。单击按钮时vids会加载,但它们不会自动播放。

The rest is standard YouTube iframe API script. You can see I tried setting Autoplay=1 as both an iframe parameter and as part of the iframe src. I've also tried including it in the data in the button. None of these seems to work. The vids load when the buttons are clicked, but they don't autoplay.

推荐答案

自2018年4月起它没有工作因为Google决定更好地控制用户的播放。您只需要在网址中添加& mute = 1即可。
自动播放政策更改

It's not working since April of 2018 because Google decided to give greater control of playback to users. You just need to add &mute=1 to your URL. Autoplay Policy Changes

<iframe id="existing-iframe-example"
          width="640" height="360"
          src="https://www.youtube.com/embed/-SFcIUEvNOQ?autoplay=1&mute=1&enablejsapi=1"
          frameborder="0"
          style="border: solid 4px #37474F"
          ></iframe>

这篇关于YouTube自动播放无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆