如何解决 webview 播放音频的问题

how to solve problem webview to play audio

我在 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 你的 Activity