I am struggling with setting up the loop for youtube videos using youtube player api.
The problem is that the video is not running under a loop.
Here is my c
This is what I have used for the API IFrame video loop. I noticed that you must include "playlist:VIDEO_ID" parameter. and it works. This is my example
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'VIDEO_ID',
playerVars: {
playlist: 'VIDEO_ID',
loop: 1
}
});
}
</script>