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

kneidels
  • 956
  • 6
  • 29
  • 55
  • 1
    I do remember read an answer - I think it was [this one](https://stackoverflow.com/a/54356392/12511801) - 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](https://issuetracker.google.com/). – Marco Aurelio Fernandez Reyes May 24 '21 at 15:46
  • 1
    @MarcoAurelioFernandezReyes - Thank you. Does seem like a bug. Submitted – kneidels May 25 '21 at 08:07
  • 1
    Thank you. I think this is the [ticket](https://issuetracker.google.com/issues/189158429) 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. – Marco Aurelio Fernandez Reyes May 25 '21 at 13:27
  • 1
    @MarcoAurelioFernandezReyes - Thanks, done – kneidels May 25 '21 at 20:22

3 Answers3

12

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"** – Mhd Alaa Alhaj Dec 25 '22 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>
m24197
  • 1,038
  • 1
  • 4
  • 12
  • 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 '21 at 21:54
  • 2
    Wow, that is something I learned new, thank you. – m24197 May 31 '21 at 01: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.

ethry
  • 731
  • 6
  • 17