Hello,
Welcome to our Microsoft Q&A platform!
The default value of this property is false for iPhone and true for iPad, refer to https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1614793-allowsinlinemediaplayback
I test the code, the video plays inline in iPhone , iPad simulator will always show "Your browser does not support full screen", it will not be full screen whether I set Configuration.AllowsInlineMediaPlayback
to true
or false
. So I change the renderer and set false
, it works, you could have a try.
public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
{
WKWebView _wkWebView;
protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
var config = new WKWebViewConfiguration();
config.AllowsInlineMediaPlayback = false;
_wkWebView = new WKWebView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Size.Width, UIScreen.MainScreen.Bounds.Size.Height), config);
//transparent background
_wkWebView.BackgroundColor = UIColor.Clear;
_wkWebView.ScrollView.BackgroundColor = UIColor.Clear;
_wkWebView.Opaque = false;
SetNativeControl(_wkWebView);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == "Uri")
{
Control.LoadRequest(NSUrlRequest.FromUrl(new NSUrl("https://www.youtube.com/watch?v=JH8ekYJrFHs")));
}
}
}
I'm afraid the key point is the constructor method, but when I change this property in public MyWebViewRenderer(WKWebViewConfiguration config) : base(config)
and public MyWebViewRenderer() : this(new WKWebViewConfiguration())
, it still doesn't work. You could test it.
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.