Embedding YouTube video with playlist argument sometimes shows "This video is unavailable"

199 Views Asked by At

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?

1

There are 1 best solutions below

7
Mauricio Arias Olave On

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>