fancybox + jwplayer(带html5后备)

时间:2014-01-30 23:39:04

标签: javascript jwplayer fancybox-2 jplayer

我正在尝试设置fancybox来显示视频。我更喜欢玩家,但我试图用jwplayer来做这个例子: jwplayer in fancybox not playing on ipad/iphone

然而,我没有成功。你能帮我一下吗?

我正在加载这些:

  <?php echo css('assets/fancybox/jquery.fancybox.css') ?>
  <?php echo css('assets/jplayer/skin/blue.monday/jplayer.blue.monday.css') ?>

  <?php echo js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js') ?>
  <?php echo js('assets/fancybox/jquery.fancybox.js') ?>
  <?php echo js('assets/fancybox/helpers/jquery.fancybox-media.js') ?>
  <?php echo js('assets/js/fancybox.js') ?>

  <?php echo js('assets/jwplayer/jwplayer.js') ?>
  <?php echo js('assets/jwplayer/jwplayer.html5.js') ?>

在fancybox.js中,我这样做:

$(document).ready(function() {
  $(".video_popup").fancybox({
  fitToView: false, 
  scrolling: 'no', 
  content: '<div id="myvideo"></div>',
  afterShow: function () {
   jwplayer('myvideo').setup({
        file: this.href,
        autostart: 'true',
         modes: [
        {type: 'flash', src: 'assets/jwplayer/jwplayer.flash.swf'},
        {type: 'html5', config: {file: this.href, provider: 'video'}},
    ]
    });
  }
});

我正在调用这样的视频:

<a href="spline-01.mp4" class="video_popup"> here to start movie no 11</a><br><div id="myvideo"></div>

2 个答案:

答案 0 :(得分:0)

我写了一个灯箱,我会尝试一下。

https://github.com/emaxsaun/jwbox

答案 1 :(得分:0)

我终于设法解决了这个问题。下一步:用jplayer替换jwplayer。

<a class="jwVideo" spline-01.mp4" rel="group"> Preview </a>

$(function() {
    $("a.jwVideo").click(function() {
        var myVideo = this.href; // Dont forget about 'this'

        $.fancybox({
            padding : 0,
            content: '<div id="video_container">Loading the player ... </div>',
            afterShow: function(){
                jwplayer("video_container").setup({ 

                    file: myVideo,
                    width: 640,
                    height: 385,
                    modes: [
        { type: 'html5' },
        { type: 'flash', src: 'assets/jwplayer/jwplayer.flash.swf' }
    ]

                });
            }
        });
        return false;
    });
});