Fancybox-嵌入式YouTube(使用YouTube API)没有't在iOS上加载
Fancybox - Embedded YouTube (using YouTube API) doesn't load on iOS
我正在使用Fancybox来显示上传到YouTube的视频。我想在视频结束时执行操作(在这种情况下,从视频移动到组中的下一个元素-图像),所以我也在使用YouTube API。
这个页面在桌面浏览器上运行得很好(我认为是安卓系统,但我还没有广泛测试过),但在我的iPhone上,它无法加载视频。覆盖正在出现,但它似乎试图自动播放视频,然后变成黑色。
我目前正在使用jQuery 1.8.3(我用1.10尝试过,但没有成功,所以我尝试了降级)和Fancybox 2.1.5。
以下是相关的HTML:
<div class="content" id="main">
<div id="logo">
<a class="fancybox fancybox.iframe" id="logo-link" data-fancybox-group="group01"href="http://www.youtube.com/embed/Bc0qNwaSxlM"></a>
<a class="fancybox" id="v-link" data-fancybox-group="group01" data-fancybox-type="image" href="img/superhard_v.png" title="<a href='#' id='return-link'>or return to ihardyou</a>"></a>
</div>
</div>
JavaScript:
window.onYouTubePlayerAPIReady = function() {
// Initialise the fancyBox after the DOM is loaded
$(document).ready(function() {
$(".fancybox")
.attr('rel', 'gallery')
.fancybox({
helpers: {
media: {},
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.95)'
}
}
},
youtube : {
vq: 'hd1080'
},
padding: 0,
margin: 30,
autoSize: false,
arrows: false,
'closeBtn' : false,
beforeShow : function() {
// Find the iframe ID
var id = $.fancybox.inner.find('iframe').attr('id');
// Create video player object and add event listeners
var player = new YT.Player(id, {
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
if (this.index === 1) {
$('.fancybox-outer').css("padding-bottom","100px");
}
},
afterShow: function() {
if (this.index === 1) {
$("img.fancybox-image").click(function(event) {
event.preventDefault();
newLocation = "vanity/";
$('body').fadeOut(1000, newPage);
});
$('#return-link').click(function(event) {
event.preventDefault();
$.fancybox.close();
});
}
},
tpl: {
wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin" style="background-color:transparent;"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>'
},
iframe: {
preload: false
}
});
});
}
function onPlayerReady(event) {
event.target.playVideo();
}
// Fires when the player's state changes.
function onPlayerStateChange(event) {
// Go to the image after the current one is finished playing
if (event.data === 0) {
setTimeout(function(){$.fancybox.next()},1250);
}
}
我为iframe
输入了autoSize
和preload: false
,因为我遇到了其他人的问题,但它们不起作用。由于这个问题和JSFiddle的例子,我特别希望后者能起作用,但它没有起作用,这让我相信这可能是API的问题?我还在Fancybox主页上查看了使用API的示例,但它在我的iPhone上也不起作用,这进一步证实了我的怀疑。
如果有人有解决方法或任何解决方法,我们将不胜感激。谢谢
为什么不重新检查fancybox网站中使用的各种示例:
您可以尝试以下操作:*Html*
<li>
<a class="various fancybox.iframe" href="http://www.youtube.com/embed/L9szn1QQfas?autoplay=1">Youtube (iframe)</a>
</li>
Javascript:
$(document).ready(function() {
$(".various").fancybox({
maxWidth : 800,
maxHeight : 600,
fitToView : false,
width : '70%',
height : '70%',
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none'
});
});
我们检查他们的官方小提琴为youtube iframe:这是他们的小提琴
Html:
<!-- This loads the YouTube IFrame Player API code -->
<script src="http://www.youtube.com/player_api"></script>
<a class="fancybox fancybox.iframe" href="http://www.youtube.com/embed/L9szn1QQfas?enablejsapi=1&wmode=opaque">Video #1</a>
<br />
<a class="fancybox fancybox.iframe" href="http://www.youtube.com/embed/cYplvwBvGA4?enablejsapi=1&wmode=opaque">Video #2</a>
您可以查看中的剩余部分
相关文章:
- HtmlUnit无法在youtube上完全加载页面
- 如何在PHP数组中加载下一个youtube
- 提交youtube播放列表id并从id加载播放列表
- 借助JS/Jquery函数,通过其URL加载youtube视频
- YouTube Fancybox未加载视频
- YouTube Javascript API:加载在 Firefox 中不起作用
- 在AngularJS中嵌入Youtube视频在加载页面时会生成错误
- 在页面加载后插入 YouTube iframe
- Youtube API 未在 Firefox 中加载
- YouTube播放列表 - 在页面加载时显示播放列表
- 如何在页面加载 10 秒后自动播放 YouTube 视频
- 在 Meteor 中加载 youtube 播放器 API
- 通过jQuery/JS加载的Youtube视频
- 如何根据内容所有者将Youtube货币数据加载到HTML
- 在 iframe 中加载 Youtube Player API
- 用于 iFrame 嵌入的 youtube 参考 API 未加载 iFrame
- Rails & Youtube API:加载 iframe 时出现问题
- YouTube API 视频结束加载一个函数
- 附加的火狐在YouTube评论加载后自动调用JavaScript
- 事件加载 jQuery 和 YouTube API