По симптомам похоже на проблему с загрузкой. В инспекторе ошибок не отображается.
Вот мой код:
HTML
Код: Выделить всё
videoId = 'someVideoId';
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
(вызывается в конце страницы. Я пытался разместить код сразу после приведенного выше скрипт и результат был тот же.)
Код: Выделить всё
var isReady = false
, player
, poster
, video;
$(function () {
$('.js-play').click(function (e) {
e.preventDefault();
interval = setInterval(videoLoaded, 100);
});
});
function onYouTubeIframeAPIReady() {
console.log(videoId)
player = new YT.Player('player', {
height: '445',
width: '810',
videoId: videoId,
events: {
'onReady': onPlayerReady//,
//'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
isReady = true;
console.log("youtube says play")
}
function videoLoaded (){
if (isReady) {
console.log("ready and play")
poster.hide();
video.show();
$('body').trigger('fluidvideos');
player.playVideo();
clearInterval(interval);
}
}
На мобильных телефонах такое происходит постоянно. Есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/122 ... meapiready
Мобильная версия