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

Disable auto fullscreen of YouTube embeds on iPhone

正如我们从网站上的其他问题到 iOS Mobile Safari 中所知道的那样,我们有这些美味的属性 webkit-playesinline 和更简洁的 playsinline 来禁用视频的自动全屏。

尽管出现了这个奇迹,但我仍然无法弄清楚如何将其添加到 YouTube html5 嵌入中。正如预期的那样,YouTube <video> 包含在 <iframe> 中。

理想的结果如下:

<video 
    tabindex="-1" 
    class="video-stream html5-main-video" 
    style="width: 736px; height: 414px; left: 85px; top: 0px;" 
    src="blob:https://www.youtube.com/6889sdad6d2-ec51-49ca-b357-a5bd9c3ede71" 
    webkit-playsinline="true" 
    playsinline="true">
</video>

我曾尝试通过 jquery 执行此操作,但没有成功。

有什么想法或想法如何做到这一点?

playsinline=1 参数添加到嵌入 url。酌情在前面加上?&? 如果是唯一的参数,& 与其他参数连接。

示例:

<iframe
  src="https://www.youtube.com/v/VIDEO_ID?playsinline=1">
</iframe>

来自YouTube iFrame Player API

This parameter controls whether videos play inline or fullscreen in an HTML5 player on iOS. Valid values are: 0: This value causes fullscreen playback. This is currently the default value, though the default is subject to change. 1: This value causes inline playback for UIWebViews created with the allowsInlineMediaPlayback property set to TRUE.

根据当前 API 描述,playsinline 应设置为 0 以避免在 iOS 设备上全屏显示。

查看以下描述,发现于:https://developers.google.com/youtube/player_parameters