Forum Xamarin Xamarin.Forms

WebView embedded youtube video issue

I am using Xamarin Forms WebView to play an embedded youtube video but it seems as though some of the parameters for the source and iframe are being ignored. This is when running Android. I am unable to get allowfullscreen to work as well as autoplay and modestbranding. When I use the created html on a regular browser (IE, Chrome) everything seems to work. I have even tried creating a custom WebView renderer so I can play with the Android settings but still not luck.

The HTML creation:

string s_source = string.Format("{0}?autoplay=1&showinfo=0&color=white&rel=0&modestbranding=1", VideoSource);

string s_iframe = string.Format( "<iframe src=\"{0}\" frameborder=\"0\" " + "allowfullscreen></iframe>", s_source);

string html = string.Format( "<!DOCTYPE html><html><head>" + "<style>" + "html, body {{ height: 100%; width: 100%; }} " + "html {{ display: table; margin: auto; }} " + "body {{ background-color: black; display: table-cell; vertical-align: middle; }}" + "iframe {{ width: 100%; }}" + "</style>" + "</head><body>{0}</body></html>", s_iframe);

return html;

Loading into the WebView:

//Load the dynmically created HTML _webView.Source = new HtmlWebViewSource() { Html = createHtml(), };

Sign In or Register to comment.