android - 如何解决问题 webview 播放音频
问题描述
我使用我的网站WebView
来创建我的网站的应用程序。我的网站有一个部分可以播放来自其他网站的声音。我的网站是https
,其他网站是http
。当想播放这首歌时,从 android studio 得到这个错误
E/EGL_emulation: eglQueryContext 32c0 EGL_BAD_ATTRIBUTE
E/EGL_emulation: tid 3170: eglQueryContext(1456): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/chromium: [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://mysiteurl' was loaded over HTTPS, but requested an insecure video 'http://othersiteurl'. This request has been blocked; the content must be served over HTTPS.", source: https://mysiteurl (0)
I/chromium: [INFO:CONSOLE(0)] "Uncaught (in promise) NotSupportedError: Failed to load because no supported source was found.", source: undefined (0)
我该如何解决这个问题
解决方案
你必须添加
android:usesCleartextTraffic="true"
到 AndroidManifest.xml 中的应用程序标签并添加
if (Build.VERSION.SDK_INT >= 21) {
mWebView.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_ALWAYS_ALLOW );
}
进入 OnCreate 你的活动
推荐阅读
- google-apps-script - 在 Google Apps 脚本中将一维数组重新整形为二维数组
- css - nth-of-type(1) 和 first-of-type 伪类之间的区别
- javascript - 在 JavaScript 中转换日期时间时区
- nestjs - Nestjs 将 JSON arra 转换为字符串 []
- wpf - WPF C#在堆栈面板中显示图像
- javascript - Typescript Promise 循环中的数据流和内存问题
- python - pyautogui 和 win32gui 截图背景窗口
- python - 在python中调用某个函数进行测试时如何触发代码段
- python - 从 SSHOperator 解码 UTF-8 编码的 Xcom 值
- python - 使用 ../../ 访问文件