使用JWPlayer 6将Fancybox2的图像和视频放在同一组中 [英] Fancybox2 with images and video in the same group using JWPlayer 6
本文介绍了使用JWPlayer 6将Fancybox2的图像和视频放在同一组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个将图像和视频混合在一起的画廊组,并使用JWPlayer6将视频与视频相混合.
I'm trying to create a gallery group that mixes images and video, with the video using JWPlayer6.
我每个人都作为独立的小组工作,但是我无法锻炼如何将两者结合在一起.
I have each working as separate groups, but I can't workout how to integrate the two.
<!-- 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>
推荐答案
好吧,我不确定这是肯尼迪国际机场提出的建议,但这似乎可行,尽管必须有一种更有效的方法来做到这一点:>
Ok, I'm not sure this is what JFK was suggesting but this seems to work, although there must be a more efficient way to do it:
<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>
这篇关于使用JWPlayer 6将Fancybox2的图像和视频放在同一组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文