iOS 视频在线播放并不总是在 swift 应用中在线播放

iOS Video playsinline not always playing inline in swift app

我使用 YouTube api 在 Ios 上显示 Youtube。我在显示它时没有问题,但是当我点击视频时,它不断地变成 full screen,这个问题在 Android 上正常工作,但只是不为 Ios

工作

html 文件

<div id="video_iframe"></div>

js文件

var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
function onYouTubeIframeAPIReady() {
  player = new YT.Player("video_iframe", {
    height: "720",
    width: "720",
    videoId: video_code,
    playerVars: {
      controls: "0", 
      start: video_start,
      end: video_end,
      mute: "0", 
      rel: "0", 
      playsinline: "1"
    }
  });
}

有没有人解决过和我一样的问题?我正在使用 WKWebview.

Youtube iFramePlayerApi 说:

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.

为您的 WKWebView

allowsInlineMediaPlayback 设置为 true