我遇到了一个问题,即网页使用 SSL 进行保护,但页面内的视频和音频内容没有,源 url 是 HTTP,这会阻止用户在 WebView 内播放这些类型的内容。消息如下:
"Mixed Content: The page at 'https://<page url>' was loaded over HTTPS, but requested an insecure video 'http://<video url>.mp4'. This request has been blocked; the content must be served over HTTPS.", source: https://<page url> (0)
是否可以以某种方式允许或强制 WebView 加载混合内容并允许用户播放未使用 SSL 保护的内容?
谢谢
答案 0 :(得分:0)
webview_flutter
插件没有更改 Android WebView 混合内容模式的选项。
相反,您可以使用我的 flutter_inappwebview 插件,该插件支持该特定的 Android webview 选项。
在您的情况下,您可以将 Android webview 选项 mixedContentMode
设置为值 AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW
在这种模式下,WebView 将允许安全来源从任何其他来源加载内容,即使该来源不安全。
代码示例:
child: InAppWebView(
initialUrlRequest: URLRequest(url: Uri.parse("https://yourwebsite.com")),
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
mixedContentMode: AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW
)
),
)