0

I tried to include a Youtube video on a HTML page using the official "embed" code provided by Youtube and got an error Video not available, watch on youtube when displaying the page containing the given code:

<iframe width="560" height="315" src="https://www.youtube.com/embed/ngywWphI7tk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

A minimal working example with 2 embedded videos, the first not working and the second one working:

<p>Test</p>
<iframe width="662" height="408" src="https://www.youtube.com/embed/ngywWphI7tk" title="Set Me on Fire" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

<iframe width="560" height="315" src="https://www.youtube.com/embed/ZyDO4rMbSQA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

I found that another website successfully embedded the video I failed to embed: https://www.musicme.com/Pendulum/videos/Set-Me-On-Fire-6E6779775770684937746B.html with following code:

<iframe width="662" height="408" src="https://www.youtube.com/embed/ngywWphI7tk" title="Set Me on Fire" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

And even when I used directly this code (only difference was about dimensions), it failed on my side.

What can be the reason? How could I fix it? My current lead is that they might load it through JS so may interact with youtube API?

Ldm
  • 38
  • 6
  • 1
    Check in your page if any error occurs - I tested your video on jsfiddle - [as I mentioned in this answer](https://stackoverflow.com/a/72561728/12511801) - and it works. If possible, press F12 and check the "network" tab and see if there are any errors that might explain why that specific video is not working on your page. – Marco Aurelio Fernandez Reyes Aug 02 '22 at 20:19
  • Thank you for the advice, indeed it works on jsfiddle, and the link you provided made me find that it can occur when the website is found via an **IP** and not a **hostname**. In my case it is a hostname, but hosted on a VM on AWS so it could be the issue, but I can't see how to fix it. – Ldm Aug 03 '22 at 07:19
  • I double checked and this is not a hostname issue since another subdomain with the same stack is working. I figured out that i was customizing the iframe embedding code, so the problem is surely at this level. – Ldm Aug 03 '22 at 07:40

0 Answers0