【问题标题】:Video will not autoplay when clicked单击时视频不会自动播放
【发布时间】:2014-05-14 02:43:07
【问题描述】:

由于某种原因,我的视频在点击时不会自动播放。我已将我的视频元素设置为:

<video id="epsilon_launch" class="video-js vjs-default-skin" preload="auto" data-setup="{}" width="920" height="518" controls autoplay>
<source src="video/epsilon_launch.mp4" type="video/mp4">
</video>

它在使用 IE8 时正确自动播放(.swf 用于非 HTML5 浏览器的后备)。 Live link here.

【问题讨论】:

  • 看看这篇文章——可能会有所启发:stackoverflow.com/questions/8184677/html5-video-with-fancybox
  • 感谢您的提示。不幸的是,我不知道如何在我的代码中实现该解决方法。
  • 如果你使用data-setup='{"autoplay":true}'而不是autoplay,它是否有效?
  • 好像没有:(
  • 伙计们,它可以在我办公室的电脑上运行,但不能在家里的电脑上运行。不管怎样,这才是最重要的。

标签: html html5-video fancybox-2 video.js


【解决方案1】:
<script> 
var myVideo=document.getElementById("epsilon_launch"); 
 myVideo.play(); 
</script>

试试这个

【讨论】:

    【解决方案2】:

    我会这样做。

    $("a#videolink").fancybox({
        frameWidth: 920,
        frameHeight: 518,
        padding: 0,
        scrolling: 'no',
        afterShow: function() { _V_(this.href.replace('#','')).play() }
    });
    

    this.href 中,这是对链接的引用,因此获取href 属性并删除# 会为您提供视频的ID。使用它,您可以使用 V 方法获取对播放器的引用并告诉它播放。

    仅供参考:您使用的是相当旧版本的 video.js

    【讨论】:

      猜你喜欢
      • 2019-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-18
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      相关资源
      最近更新 更多