2

我正在尝试创建一个混合图像和视频的画廊组,视频使用 JWPlayer6。

我让每个人都作为单独的小组工作,但我无法锻炼如何将两者结合起来。

<!-- FancyBox to display images -->
<script type="text/javascript">
    $(document).ready(function() {
      $(".fancybox").fancybox({
        helpers : { 
      title : { type : 'inside' }
      }, // helpers
        beforeLoad: function(){
        }
      });
    });

<!-- FancyBox to display videos -->
<script type="text/javascript">
   $(document).ready(function() {
     $(".fancybox-video").fancybox({
        content: '<div id="video_container" style="">Loading video...</div><br>',
        autoSize: true,
        helpers : { 
          title : { type : 'inside' }
           }, // helpers
        beforeLoad: function(){
           this.title = $(this.element).attr('caption');
           },
        afterShow: function(){
           jwplayer("video_container").setup({
             flashplayer: "/static/js/libs/jwplayerjwplayer.flash.swf",
             file: this.href,
             autostart: 'true'
             }); // jwplayer setup
           } // afterShow
        }); // fancybox
 }); // on
</script>
4

1 回答 1

2

好的,我不确定这是 JFK 的建议,但这似乎可行,尽管必须有更有效的方法来做到这一点:

<style type="text/css">
.fancybox-nav {
height: 80%;
}
</style> 

<script type="text/javascript">
    $(document).ready(function() {
  $(".fancybox").fancybox({
        autoSize: true,
        helpers : { 
          title : { type : 'inside' }
          }, // helpers
        beforeLoad: function(){
          if($(this.element).attr('containertype')=='video'){
            this.content = '<div id="video_container" style="">Loading the player ... </div><br>';
          };
          },
        afterShow: function(){
          if($(this.element).attr('containertype')=='video'){
            jwplayer("video_container").setup({
            flashplayer: "jwplayer.flash.swf",
            file: this.href,
            autostart: 'true'
          }); // jwplayer setup 
          }; 
        }// afterShow
   }); // fancybox
 }); // on
</script>

和 HTML:

<a class="fancybox" rel="group" title="Video 1" data-fancybox-type="anything" containertype="video" href="1.flv"><img src="1.png"/></a>
<a class="fancybox" rel="group" title="Image 2"  href="2.png"><img src="2.png"/></a>
于 2013-03-11T21:22:51.077 回答