hong developer
hong developer

Reputation: 13926

iOS Video playsinline not always playing inline in swift app

I use YouTube api to show Youtube on Ios. I don't have a problem showing it, but when I click on the video, it's constantly changing to the full screen, and this is a problem that works normally with the Android, but only don't work for Ios

html file

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

js file

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"
    }
  });
}

Has anyone solved the same problem as me? I am using WKWebview.

Upvotes: 1

Views: 742

Answers (1)

Ravi
Ravi

Reputation: 2451

Youtube iFramePlayerApi says :

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.

set allowsInlineMediaPlayback to true for your WKWebView

Upvotes: 1

Related Questions