Search code examples
htmliframeyoutube

Youtube iframe "loop" doesn't work


I tried to use the YouTube player demo to generate the code necessary for my video to autoplay and loop itself. But only the autoplay works, it doesn't loop, and the demo-video doesn't work either. Here is the code I've used.

<iframe class="embed-responsive-item" id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?&autoplay=1&loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3" frameborder="0" allowfullscreen>
</iframe>

Solution

  • Try adding the playlist parameter along with the loop. For playlist, set it's value as the current video id.

    <iframe class="embed-responsive-item"id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?&autoplay=1&loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"
          frameborder="0" allowfullscreen></iframe>
    

    Currently, the loop parameter only works in the AS3 player when used in conjunction with the playlist parameter. To loop a single video, set the loop parameter value to 1 and set the playlist parameter value to the same video ID already specified in the Player API URL:

    http://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID
    

    Reference:https://developers.google.com/youtube/player_parameters#loop