Embed Youtube code is not working in HTML

吃可爱长大的小学妹 提交于 2019-12-12 19:15:10

问题


I am trying to use embed youtube code in HTML but when I press play button it say "This video is unavailable". I am using the following HTML code for it:

<iframe width="560" height="315" src="https://www.youtube.com/embed/JfJYHfrOGgQ" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Can anyone help me out with this? I have tried other embed youtube videos too, still says same thing. I am using Chrome.


回答1:


I had the same issue recently and it had nothing to do with video owners embedding settings. Apparently YouTube forbids embedding some videos in a localhost environment without a public domain, but your video can be embedded with no issue whatsoever through a public domain/subdomain: Replace the src value in the JSFiddle from @PStarczewski's answer with your video link and it will work properly.




回答2:


On YouTube there is so called "embed settings" where owner of the video can decide whether or not to allow for it.

Here is an example: JSFiddle

<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLsyvDWwjkTqtOmqAiTzzfHspTAztB-udL" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/JfJYHfrOGgQ" frameborder="0" gesture="media" allow="autoplay; encrypted-media" allowfullscreen></iframe>

And here you can find more details about this: YouTube Restrict embedding




回答3:


I just came to know It depends on Owner. If owner enables the embedded settings then you can add this links to your Html. just for example 1st add famous videos (which has more than 1M likes i.e songs) then add any video which has like 1k like.



来源:https://stackoverflow.com/questions/51424578/embed-youtube-code-is-not-working-in-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!