Search code examples
youtubeembed

Loop parameter not working on youtube embed


I am using the following code:

 <iframe src="https://www.youtube.com/embed/AAAAAAAAA?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" 
frameborder="0" allowfullscreen></iframe>

Autoplay works, when mute=1 But it only plays once - it seems that the loop=1 is being ignored, and it just stops after once cycle, and displays suggested videos from this channel (related videos are being prevented bu the rel=0 parameter, but its still showing suggested in-channel video, after a single loop).

Any ideas how to get the loop to work? I have tried via the sample here too: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_youtubeiframe_loop Thanks


Solution

  • Add the playlist parameter and set its value as the current video Id. This should work just fine.

     <iframe src="https://www.youtube.com/embed/AAAAAAAAA?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1&playlist=AAAAAAAAA" 
    frameborder="0" allowfullscreen></iframe>