我在android kitkat webview中显示youtube视频时遇到问题。每当我尝试播放视频时,它总是会崩溃并显示消息“执行本机代码时获得了SIGSEGV” 从崩溃的角度来看,消息是“无法解析主机”www.youtube.com“:没有与主机名相关联的地址” 这只发生在Kitkat及以下
我已经将hardwareAccelerated设置为true,还设置了SetWebChromeClient
有关信息,我使用Xamarin表单并使用自定义渲染器进行webview。这是自定义渲染器的代码
this.Control.Settings.JavaScriptEnabled = true;
this.Control.Settings.LoadWithOverviewMode = true;
this.Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
this.Control.Settings.DomStorageEnabled = true;
this.Control.Settings.SetRenderPriority(WebSettings.RenderPriority.High);
this.Control.Settings.AllowFileAccess = true;
this.Control.Settings.SetPluginState(WebSettings.PluginState.OnDemand);
if(App.AndroidOSVersion>16)
this.Control.Settings.MediaPlaybackRequiresUserGesture = false;
if (UI.AllowFullScreen)
this.Control.SetWebChromeClient(new WebChromeClient());
this.Control.LoadDataWithBaseURL(null, UI.YoutubeSource, "text/html", "UTF-8", null);