Reputation: 1592
I have an open URL in WKWebview on this web-page show this contains a youtube video view but in WKWebview it's by default show in full screen.
how to show youtube video as inline or show as it's the frame size, I have implemented all below code but not getting success.
var configuration = new WKWebViewConfiguration();
configuration.Preferences = preferences;
configuration.AllowsInlineMediaPlayback = true;
configuration.MediaPlaybackRequiresUserAction = true;
webView = new WKWebView(Frame, configuration);
Upvotes: 1
Views: 456
Reputation: 5109
I tried to do something similar, to display the video on my device screen, and I found that the only free way to do this because of YouTube's strict rules, is by loading the embed through HTML on a webView page.
I has to add a lot of properties to properly define the embed size. And as you can see in the picture, it worked!
This is the code I ended up have to use:
var html = string.Format("<html>{0}<body><iframe width='{1}' height='{2}' src='{3}' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe></body></html>",header, screenWidth, playerHeight, videoUrl);
Here's the sample where I finally ended up doing it in Xamarin Forms.
Upvotes: 1