Код: Выделить всё
/* 2. This code loads the IFrame Player API code asynchronously.
*/
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
/* 3. This function creates an (and YouTube player) after the API code downloads.
*/
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
videoId: 'xbiEN3jGi00',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
},
playerVars: {
'autoplay': 1,
'loop': 1,
'controls': 0,
'rel' : 0,
'showinfo': 0,
}
});
}
/* 4. The API will call this function when the video player is ready.*/
function onPlayerReady(event) {
event.target.playVideo();
player.mute();
}
/* 5. The API calls this function when the player's state changes.
The function indicates that when playing a video (state=1),
The player should play for six seconds and then stop.
*/
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING ) {
player.playVideo();
}
}
Код: Выделить всё
Див «player» является целью API JavaScript для встраивания видео YouTube.
Моя проблема в том, что опция «цикл» не работает для моего
видео.
В чем моя ошибка?
Какой параметр мне следует установить?
Заранее спасибо за помощь
Подробнее здесь: https://stackoverflow.com/questions/382 ... ot-looping
Мобильная версия