2010-12-10 23 views
0
I have links with vimeo urls in them: 

    <a class="video" href="http://vimeo.com/9532951">link 1</a> 
    <a class="video" href="http://vimeo.com/8228482">link 2</a> 

Then I have manual fancybox call that loads the video into a fancybox: 

    <script> 
$("a.video").click(function() { 
    $.fancybox({ 
    'padding' : 0, 
    'autoScale' : false, 
    'transitionIn' : 'none', 
    'transitionOut' : 'none', 
    'title' : this.title, 
    'width' : 400, 
    'height' : 265, 
    'href' : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'), 
    'type' : 'swf' 
    }); 

    return false; 
}); 
</script> 

我不能爲我的生活弄清楚如何將參數傳遞給視頻播放器...... autoplay = 1或fullscreen = 1等等等等等等等等。我嘗試了幾件事情,但都沒有奏效。正在考慮這是像添加'swf' : 'autoplay=1',但沒有奏效。無論如何,任何幫助將不勝感激是否有可能通過帶有動態hrefs的jQuery函數傳遞Vim​​eo播放器變量?

謝謝。

回答

0

嘗試增加

'swf' : {'allowfullscreen':'true', 'autoplay':'1'} 
+0

試過這個,但它不工作。還嘗試追加href調用 'href':this.href.replace(new RegExp(「([0-9])」,「i」),'moogaloop.swf?clip_id = $ 1'+'&autoplay = 1 '), 我認爲fancybox只是解析帶有附加自動播放功能的網址時遇到問題。 – Reece 2010-12-10 15:42:37

0

我已經找到一種方法,你可以做到這一點。一個unike ID添加到eatch您的鏈接,並設置呼叫他們,因爲這

$("a.video").click(function() {
var video_fancybox = {
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : 400,
'height' : 265,
'href' : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
};
$("#vimeo_test3").fancybox(// On for eatch link
$.extend(video_fancybox, {'href' : 'http://vimeo.com/moogaloop.swf?clip_id=3979490&amp;fullscreen=1'})
);
return false;
});

+0

鏈接看起來像是`link 1`Rember在** $。extend(video_fancybox ** line)中具有相同的視頻ID – Tyde 2010-12-13 13:04:22

1

這裏不需要一個唯一的ID另一種可行的解決方案:

$(".vimeo").click(function() { 
    $.fancybox({ 
     'padding'  : 0, 
     'overlayShow' : true, 
     'overlayOpacity': .85, 
     'overlayColor' : '#000', 
     'autoScale'  : false, 
     'transitionIn' : 'elastic', 
     'transitionOut' : 'elastic', 
     'title'   : this.title, 
     'width'   : 680, 
     'height'  : 393, 
     'href'   : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1')+'&amp;autoplay=1', 
     'type'   : 'swf' 
    }); 
    return false; 
}); 
0

只要確保將「autoplay」替換爲「autostart」並將其設置爲「true」。閃存播放器不理解「自動播放」作爲命令。 代碼將如下所示:

$('#vimeo_video').click(function(){ 
    $.fancybox({ 
     'padding'  : 0, 
     'autoScale'  : true, 
     'transitionIn' : 'elastic', 
     'transitionOut' : 'elastic', 
     'title'   : this.title, 
     'width'   : 790, 
     'height'  : 450, 
     'href'   : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1')+'&amp;autoplay=true', 
     'type'   : 'swf', 
     'swf'   : { 'wmode' : 'transparent', 'allowfullscreen' : 'true', 'autostart' : 'true' } 
    }); 
    return false; 
}); 

$("#vimeo_video").trigger('click'); 
相關問題