嵌入youtube视频——拒绝在帧中显示,因为它将“x帧-选项”设置为“SAMEORIGIN”[复制]

时间:2021-08-22 13:46:24

This question already has an answer here:

这个问题已经有了答案:

I am trying to feed my django page with some resource I am getting from somewhere else.

我正试图用我从别处获得的一些资源来充实我的django页面。

inside feed, I have youtube videos with url like: https://www.youtube.com/watch?v=A6XUVjK9W4o

在feed中,我有youtube视频,网址是:https://www.youtube.com/watch?

once I added this into my page, video doesnot show up saying:

一旦我把它添加到我的页面,视频就不会出现:

Refused to display 'https://www.youtube.com/watch?v=A6XUVjK9W4o' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

拒绝显示的https://www.youtube.com/watch?v=A6XUVjK9W4o,因为它将“X-Frame-Options”设置为“SAMEORIGIN”。

Then I said, well, what if I change watch to embed. Then youtube player shows up, but no video, saying:

然后我说,好吧,如果我换一块手表。然后youtube播放器出现了,但没有视频,说:

嵌入youtube视频——拒绝在帧中显示,因为它将“x帧-选项”设置为“SAMEORIGIN”[复制]

does anyone have a clue how I get this to work?

有人知道我是怎么做到这一点的吗?

I am showing in html like this:

我用这样的html显示:

<iframe width="420" height="315"
    src="{{vid.yt_url}}">
</iframe>

I googled almost for an hour, no sign of success. I tried to append &output=embed.. nada..

我用谷歌搜索了一个小时,没有成功的迹象。我试着添加和输出。如果没有. .

5 个解决方案

#1


133  

Try it, please

请试一试

<iframe width="420" height="315" src="https://www.youtube.com/embed/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>

#2


23  

Youtube url in src must have embed so for instance lets say you want to share this youtube video https://www.youtube.com/watch?v=P6N9782MzFQ you should use https://www.youtube.com/embed/P6N9782MzFQ as url in src's iframe HTML code, for example:

Youtube url在src中必须嵌入,例如,我们说你想分享这个Youtube视频https://www.youtube.com/watch?你应该使用https://www.youtube.com//p6n9782mzfq作为src的iframe HTML代码中的url,例如:

<iframe width="853" height="480" src="https://www.youtube.com/embed/P6N9782MzFQ" frameborder="0" allowfullscreen ng-show="showvideo"></iframe>

mso - fareast - font - family:宋体;mso - bidi - font - family: " times new roman "; mso - bidi - theme - font:

So just replace https://www.youtube.com/watch?v= with https://www.youtube.com/embed/ and of course check for your video's ID in this sample my video ID is P6N9782MzFQ

所以就代替https://www.youtube.com/watch?在这个示例中,我的视频ID为P6N9782MzFQ。

#3


6  

You only need to copy from youtube Embed section (click on SHARE below the video and then EMBED and copy the entire iframe)

您只需要从youtube嵌入部分复制(单击视频下方的共享,然后嵌入并复制整个iframe)

#4


2  

If embed no longer works for you try with /v instead.

如果嵌入不再适用于您尝试使用/v。

<iframe width="420" height="315" src="https://www.youtube.com/v/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>

#5


0  

Along with the embed, I also had to install the Google Cast extension in my browser.

除了嵌入,我还必须在我的浏览器中安装谷歌Cast扩展。

<iframe width="1280" height="720" src="https://www.youtube.com/embed/4u856utdR94" frameborder="0" allowfullscreen></iframe>

#1


133  

Try it, please

请试一试

<iframe width="420" height="315" src="https://www.youtube.com/embed/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>

#2


23  

Youtube url in src must have embed so for instance lets say you want to share this youtube video https://www.youtube.com/watch?v=P6N9782MzFQ you should use https://www.youtube.com/embed/P6N9782MzFQ as url in src's iframe HTML code, for example:

Youtube url在src中必须嵌入,例如,我们说你想分享这个Youtube视频https://www.youtube.com/watch?你应该使用https://www.youtube.com//p6n9782mzfq作为src的iframe HTML代码中的url,例如:

<iframe width="853" height="480" src="https://www.youtube.com/embed/P6N9782MzFQ" frameborder="0" allowfullscreen ng-show="showvideo"></iframe>

mso - fareast - font - family:宋体;mso - bidi - font - family: " times new roman "; mso - bidi - theme - font:

So just replace https://www.youtube.com/watch?v= with https://www.youtube.com/embed/ and of course check for your video's ID in this sample my video ID is P6N9782MzFQ

所以就代替https://www.youtube.com/watch?在这个示例中,我的视频ID为P6N9782MzFQ。

#3


6  

You only need to copy from youtube Embed section (click on SHARE below the video and then EMBED and copy the entire iframe)

您只需要从youtube嵌入部分复制(单击视频下方的共享,然后嵌入并复制整个iframe)

#4


2  

If embed no longer works for you try with /v instead.

如果嵌入不再适用于您尝试使用/v。

<iframe width="420" height="315" src="https://www.youtube.com/v/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>

#5


0  

Along with the embed, I also had to install the Google Cast extension in my browser.

除了嵌入,我还必须在我的浏览器中安装谷歌Cast扩展。

<iframe width="1280" height="720" src="https://www.youtube.com/embed/4u856utdR94" frameborder="0" allowfullscreen></iframe>