emonigma
emonigma

Reputation: 4436

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

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://emonigma.com/pt/cancao/10 .

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

update (April 2024)

After filing an [issue]https://issuetracker.google.com/issues/284737598), the team replied:

Since the internal teams are unable to reproduce this issue. We believe this is related to restrictions the creator has put on the video as we get the same error as we don't see if it I load the video in youtube.com directly:

https://www.youtube.com/watch?v=UHOX6jH00kE

Indeed, that original video is now private, but I have the same issue with a public video, e.g. z4mGokBU3f0. It is much less frequent now: 5% of the time as opposed to 50% before.

Upvotes: 0

Views: 500

Answers (1)

Mauricio Arias Olave
Mauricio Arias Olave

Reputation: 2575

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>

Upvotes: 2

Related Questions