0

I have a website where I embed YouTube videos with this link:

https://www.youtube.com/embed/UHOX6jH00kE?autoplay=1&loop=1&list=UHOX6jH00kE

and the syntax from this thread:

<iframe src="https://www.youtube.com/embed/UHOX6jH00kE?autoplay=1&loop=1&list=UHOX6jH00kE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen)

Sometimes, this embedding works and I see the video, e.g. this page. Other times, e.g. this page the embed doesn't work and I see "This video is unavailable":

YouTube video unavailable

If I refresh the page with Cmd-R, then the video shows. If I remove the playlist GET argument, e.g. with embed link https://www.youtube.com/embed/UHOX6jH00kE?autoplay=1&loop=1, then it also shows.

Sometimes, if I check on my alternative domain (that redirects to the same server; the only difference is the default language), then I see the video, the video sometimes shows, e.g.: https://brokkolat.org/pt/cancao/10 .

How can I embed a YouTube video that loops and always shows without refreshing?

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
miguelmorin
  • 5,025
  • 4
  • 29
  • 64

1 Answers1

2

Try change your URL as follows:

https://www.youtube.com/embed/UHOX6jH00kE?autoplay=1&loop=1&rel=0&showinfo=0&color=white&enablejsapi=1

I've tested on jsfiddle and on my browser (Google Chrome) and it works.

Keep in mind that for autoplay on Google Chrome, it seems it's need to the video starts muted.

Code:

<iframe src="https://www.youtube.com/embed/UHOX6jH00kE?autoplay=1&mute=1&loop=1&rel=0&showinfo=0&color=white&enablejsapi=1">
</iframe>

Example with another video - see my answer for a detailed explanation:

<iframe src="https://www.youtube.com/embed/QwS1r1mc888?enablejsapi=1&loop=1&playlist=QwS1r1mc888&autoplay=1&mute=1&rel=0&showinfo=0&color=white">    
</iframe>
Mauricio Arias Olave
  • 2,259
  • 4
  • 25
  • 70
  • This code works on Google Chrome and loops the video. It doesn't on Safari, any ideas how to fix that? – miguelmorin May 09 '23 at 16:45
  • 1
    @miguelmorin [here](https://stackoverflow.com/a/31561351/4092887) says the issue is due the `https` on the video URL. Also [this answer](https://stackoverflow.com/a/34760448/4092887) points to add additional tags. I don't have Safari, but, please try and let us know. – Mauricio Arias Olave May 10 '23 at 14:07
  • 1
    Changing from `https` to `http` does not show the iframe, it's just blank. Changing `iframe` to `object` and `shockwave-flash` and a link like `http://www.youtube.com/v/[VIDEO_ID]` works and shows the video; adding `?autoplay=1&loop=1` shows the video and fails to loop; adding `?autoplay=1&loop=1&playlist=[VIDEO_ID]` shows the same screen the first time, "This video is unavailable`, as before. – miguelmorin May 13 '23 at 16:17
  • 1
    @miguelmorin then try to [post a ticket](https://issuetracker.google.com/issues/new?component=186600&;template=874803&hl=es&template=874803) on [Issue Tracker](https://issuetracker.google.com/issues?q=status:open%20componentid:191640&s=created_time:desc) - though, that forum is for YouTube Data API, maybe you will find some clues about how to proceed. – Mauricio Arias Olave May 27 '23 at 20:29
  • 1
    Done: https://issuetracker.google.com/issues/284737598 . Thank you Mauricio. – miguelmorin May 29 '23 at 11:06
  • I got this answer on the issue tracker: "Hi, this is a known issue. I'll report the details of your concern with our internal team. Will update this thread for any updates. Thanks." – miguelmorin May 29 '23 at 14:39
  • 1
    @miguelmorin well done. Click the `+1` on the ticket as well. Let's hope they provide an official answer. Thanks. – Mauricio Arias Olave May 29 '23 at 15:28