【问题标题】:Add image before embedded video在嵌入视频之前添加图像
【发布时间】:2013-08-02 07:24:14
【问题描述】:

我正在尝试为下面的播放器放置上面的图像。

这是我到目前为止所得到的。我想把 gif 放到嵌入视频的上方,这样播放时就可以开始加载了。

 <div id="video"><img src="images/hand.gif" width="500" height="281" />

 <iframe src="http://player.vimeo.com/video/66167649" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
 </div>

【问题讨论】:

    标签: video embed gif


    【解决方案1】:

    我最终弄清楚出了什么问题。所以基本上,除非像你所说的那样使用一些 JS,否则你不能这样做。还要确保您决定使用的 vimeo 视频的自动播放变量为 1,否则,无论您获得多么完美;它永远不会播放。

      <div id="video"><a href="#" id="showVideo"><img src="images/hand.gif" width="647" height="366" />
    

       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"          type="text/javascript"></script>
    
       <script type="text/javascript">
    
    
        $('#showVideo').click(function () {
        $('#video').fadeIn().html('<iframe src="http://player.vimeo.com/video/66167649?title=0&amp;byline=0&amp;portrait=0&amp;color=d01e2f&amp;autoplay=1" width="647" height="366" align="middle" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
    $("#showVideo").hide()
    
      });
      </script>
    

    【讨论】:

      【解决方案2】:

      根据您要执行的操作,您可以使用一些 JS 隐藏视频,直到单击图像。

      <a href="#" id="video" class="show_hide">
          <img src="images/hand.gif" width="500" height="281" />
      </a>
      
      <div class="slidingDiv">
          <iframe src="http://player.vimeo.com/video/66167649" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
      </div>
      

      一定要引用jQuery

      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" type="text/javascript"></script>
      

      JS

      <script type="text/javascript">
      
      $(document).ready(function(){
      
              $(".slidingDiv").hide();
              $(".show_hide").show();
      
          $('.show_hide').click(function(){
          $(".slidingDiv").slideToggle();
          $("#video").hide();
          });
      
      });
      
      </script>
      

      【讨论】:

      • 谢谢。在不分开的情况下尝试使其实际工作仍然有困难。
      • 你有你正在开发的页面的链接吗?
      猜你喜欢
      • 1970-01-01
      • 2012-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 2018-06-09
      • 1970-01-01
      • 2018-08-25
      相关资源
      最近更新 更多