如何在 youtube Iframe 上禁用全屏?

Posted

技术标签:

【中文标题】如何在 youtube Iframe 上禁用全屏?【英文标题】:How to disable full screen on youtube Iframe? 【发布时间】:2017-03-31 06:08:35 【问题描述】:

我有一个 div 容器和 Iframe 里面。我指定了宽度=200 和高度=200。 当我点击全屏时,视频变得模糊,质量很差。所以,我想看看是否可以在 youtube iframe 上禁用全屏。

【问题讨论】:

【参考方案1】:

您可以使用 youtube 嵌入 URL 中的 fs 参数从 youtube 嵌入视频中删除全屏选项

示例:- youtube 嵌入 URL https://www.youtube.com/embed/youtubeid

在上面的URL中添加fs的查询参数

https://www.youtube.com/embed/youtubeid5?fs=0

特别感谢ecoe

要在 iframe 中允许全屏,请在 iframe 中添加 allowfullscreen 属性

 <iframe class="iframe-embed" [src]="url_link|safe" allowfullscreen>
              </iframe>

【讨论】:

【参考方案2】:
        <iframe title="video player" src=videoSrc allowfullscreen="0"/>

React- youtube API 的全屏修复

【讨论】:

【参考方案3】:

“我在网址末尾使用了?controls=0,它解决了这个问题。”

您的回答没有解决问题,您可以切换全屏也可以双击视频。我试过allowfullscreen="0",还是不行。

?showinfo=0 也是如此;也不行。

?showinfo=0 仅在您更改链接时有效:

https://www.youtube.com/embed/Di2KMatiGAM?controls=0&showinfo=0

到:

    https://www.youtube-nocookie.com/embed/Di2KMatiGAM?controls=0&showinfo=0

【讨论】:

【参考方案4】:

当您在 youtube 上有视频时,您可以分享它。它还显示嵌入它的选项。

您的代码中可能有 &lt;iframe&gt;&lt;/iframe&gt;

我的看起来像这样:

<div class="IFR" >
    <iframe   src="https://www.youtube.com/embed/AdfFnTt2UT0 rel=0&amp;controls=1&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" donotallowfullscreen>
        <p>
            Your browser does not support Iframes <br>
            I suggest that you use Google Chrome or FireFox
        </p>
    </iframe>
</div>

这里重要的是“donotallowfullscreen”。 如果您将其设置为“allowfullscreen”,您将能够使用全屏。

TLDR:在您的 YouTube 视频所在的 iframe 代码中,在末尾添加“donotallowfullscreen”。及其固定

【讨论】:

【参考方案5】:

使用不带allowFullscreen的iframe标签来禁用播放器上的按钮,例如:

<iframe src="https://www.youtube.com/embed/12345"></iframe>

要允许全屏,只需添加allowFullscreen:

<iframe allowfullscreen="0" src="https://www.youtube.com/embed/@(item.VideoUrl)"></iframe>

【讨论】:

除了阻止 iframe 上的全屏外,您还可以禁用 youtube 视频播放器内的全屏图标。为此,请添加参数fs=0https://www.youtube.com/embed/12345?fs=0【参考方案6】:

我在网址末尾使用了 ?controls=0 并解决了问题。

【讨论】:

以上是关于如何在 youtube Iframe 上禁用全屏?的主要内容,如果未能解决你的问题,请参考以下文章

在 iPhone 上禁用 YouTube 嵌入的自动全屏

YouTube iframe 播放器 - 在 iOS 上触发全屏

YouTube iframe 无法全屏显示

如何在 React Native youtube iframe 中切换到全屏(单击 YouTube 播放器 gui 上的全屏按钮旋转到横向)?

如何禁用右键点击youtube嵌入IFRAME?

在 Youtube iframe 上滚动禁用