2014-01-30 75 views
1

我想設置fancybox來顯示視頻。我更喜歡玩家,但我試圖用jwplayer來做這件事: jwplayer in fancybox not playing on ipad/iphonefancybox + jwplayer(帶有html5後備)

但是,我沒有成功。你能幫我一下嗎?

我加載這些:

<?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> 

回答

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; 
    }); 
});