我很迷惑 . 带有标准示例的Youtube Iframe API:https://developers.google.com/youtube/iframe_api_reference?hl=de始终用于我的移动设备,现在不再起作用了..
我试过这个小提琴:http://jsfiddle.net/77PJB/3/
<div id="player"></div>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '250',
width: '444',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
event.target.playVideo();
}
与iPad,iPhone和三星galaxy nexus . 视频没有播放..有什么变化吗?
谢谢
3 回答
来自:https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations
一个简单的解决方法,具有“播放”按钮的自定义外观:
使用pointer-events: none;覆盖元素 .
pointer-events
适用于所有现代mobile browsers或只是将视频容器放在按钮上opacity: 0
.大多数移动设备都不允许使用自动播放功能,因此如果您认为它可以正常工作
如果浏览器不是移动浏览器,则仅限.playVideo() . 检测移动浏览器的方法有很多种,如下所示:Detecting a mobile browser
例如: