2013-06-25 5 views
1

Да, я знаю, что есть куча подобных вопросов, но я не нашел их полезными для меня. У меня есть ситуации, как это: (с включенным jwplayer.js и все Stuf о FancyBox)jwPlayer with fancy box

< a class="jwVideo" href="" rel="group" > Preview </a> 


$(function() {  
    $(".jwVideo").click(function() { 
      $.fancybox({ 
       'padding' : 0, 
       'autoscale' : false, 
       'transitionIn' : 'none', 
       'transitionOut': 'none', 
       'title' : this.title, 
       'width' : 640, 
       'height' : 385, 
       'href' : this.href, 
       'type' : 'swf', 
       'swf' : { 'wmode':'transparent', 
          'allowfullscreen':'true' 
       } 
      }); 
      return false; 
     }); 
    }); 

мне нужен именно этот «шаблон» сценария, так что мой вопрос, как настроить HREF атрибут для воспроизведения видео, которое находится например, https://bla-bla.something1.amazon.com/video_1.mp4.

Спасибо.

EDIT: Благодаря JFK и Этан на помощь, я решил проблему так, если кто-нибудь есть подобные проблемы, вот решение (работал для меня):

Решение:

//html 
<a class="jwVideo" href="https://bla-bla123.com/video_1.mp4" rel="group"> Preview </a> 
//js 
$(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 
       }); 
      } 
     }); 
     return false; 
    }); 
}); 
+1

наиболее закрывается попытка была с HREF =»../js/jwplayer.flash.swf?file=https://bla-bla.somethin g1.amazon.com/video_1.mp4 «. – Srle

+0

У вас есть ссылка? – emaxsaun

+0

какая версия fancybox? – JFK

ответ

0

Если вы с использованием библиотеки и FancyBox с jwplayer версии 6 вы могли бы сделать это

$(function() { //this is much better then $(document).ready(function(){}); 

    $(".jwVideo").click(function(event) { //select class attribute jwVideo assigned to a tag 
    var myVideo = $(this).attr('href'); // select the video link from a tag in jwVideo class 

    //in the fancybox jwplayer setup code assign myVideo to file 
    $.fancybox({ 
      maxWidth : 800, 
    maxHeight : 600, 
    fitToView : false, 
    width  : '70%', 
    height  : '70%', 
    autoSize : false, 
    closeClick : false, 
    openEffect : 'none', 
    closeEffect : 'none', 
     content: '<div id="video_container">Loading the player ... </div>', 
     afterShow: function(){ 
      jwplayer("video_container").setup({ 
       file: ""+ myVideo +"", 
    image: "", 
    width: '100%', 
    aspectratio: '16:9', 
    fallback: 'false', 
    autostart: 'true', 
    primary: 'flash', 
    controls: 'true' 
      }); 
     } 
    }); 

    event.preventDefault(); //prevent default click..if this isn't here then browser will download the mp4 file instead of embedding jwplayer in fancybox 
}); 


});