【问题标题】:Fancybox3 Youtube video onload and autostartFancybox3 Youtube 视频下载和自动启动
【发布时间】:2018-12-14 13:07:33
【问题描述】:

我有一个带有视频的小网站。这是一个 YouTube 视频。

但是如果fancybox出现,视频就不会自动播放了。

这是我的代码:

<section class="contact bg-primary" id="video">
  <div class="container">
    <h2>Videoteaser</h2>

      <a data-fancybox data-width="640" data-small-btn="true" data-height="360" class="btn btn-outline2 btn-xl js-scroll-trigger"ata-small-btn="true" href="https://www.youtube.com/watch?v=MkCbpgUpkMo">Videoteaser</a>
  </div>
</section>

为了自动打开,我在网站底部有这个小JS:

$('[data-fancybox]').eq(0).trigger('click');

问题在于视频不会自动启动。不管是点击按钮还是使用小JS自动打开fancybox。

只有在点击播放按钮后,视频才会开始播放。

如何让ist自动启动?

【问题讨论】:

  • 我在 Mac 上使用 Safari。你是对的,在 Mozilla 中它会自动启动。但是当我访问fancybox网站(使用Safari)时,示例视频会自动启动。
  • 在 Chrome 中它会自动启动。但不是在 Safari (Mac) 中。但在 FancyApps-Site 上它会自动启动。

标签: fancybox


【解决方案1】:

您使用的是 Chrome,对吗?那么答案很简单——因为Autoplay Policy Changes所以不会启动,见https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

除此之外 - 它工作正常https://codepen.io/anon/pen/pqyzEM?editors=1000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 2012-07-24
    • 2013-02-13
    • 2019-07-24
    • 2015-09-25
    • 2016-09-11
    • 2014-04-22
    相关资源
    最近更新 更多