8

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

4
  • 1
    I do remember read an answer - I think it was this one - about looping a video, the idea is create a manual playlist which will have 2 videos: the video you want to loop and a video_id that does not exists, in this case, the loop go back to video 1 and so on. When I tried it didn't work as expected, so, I suspect it's a bug. Consider post a tickt on Issue Tracker. May 24, 2021 at 15:46
  • 1
    @MarcoAurelioFernandezReyes - Thank you. Does seem like a bug. Submitted
    – kneidels
    May 25, 2021 at 8:07
  • 1
    Thank you. I think this is the ticket you posted. If so, please, check at the upper-left corner of the screen - there's a star to mark the ticket. I think it is important to highlight the tickets for highlight the ticket itself. Again, thank you. May 25, 2021 at 13:27
  • 1
    @MarcoAurelioFernandezReyes - Thanks, done
    – kneidels
    May 25, 2021 at 20:22

3 Answers 3

12
+50

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>
1
  • this way won't work if the video is not included in any playlist, you will have an empty video container saying "this video is unavailable" Dec 25, 2022 at 17:41
4

According to this article of Google, you can not loop any YouTube embed without a playlist.
Therefore to loop your video you must create a custom playlist on YouTube at first, then add all the videos in the playlist.
And try again with the code:

<iframe src="https://www.youtube.com/embed/VIDEOID?playlist=PLAYLISTID&controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" 
frameborder="0" allowfullscreen></iframe>
2
  • 1
    Thank you for your comment - the sample code is almost correct - the correct version would be that the video ID and playlist ID are identical, as per the article you linked to. Thank you!
    – kneidels
    May 30, 2021 at 21:54
  • 2
    Wow, that is something I learned new, thank you.
    – m24197
    May 31, 2021 at 1:29
0

Seems like a bug.

This worked for me:

<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?playlist=bPZSDBvDmVw&mute=1&loop=1">

I think the playlist part is whats affecting it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.