Project error:
"Mixed Content: The page at 'https://wx.vzan.com/live/tvchat-427320897?v=637539910901869888#/' was loaded over HTTPS,
but requested an insecure video 'http://i3.vzan.cc/m3u8/20200221/a487a8d9b2164043bb632165a0cc129c/v.f24306.m3u8'.
This request has been blocked; the content must be served over HTTPS.",
source: https://wx.vzan.com/live/tvchat-427320897?v=637539910901869888#/ (0)
Error analysis:
Starting from 9.0 (API level 28) on Android, plaintext communication support is disabled by default, which is officially said to be unsafe. Because the video source we play is HTTP protocol, we can’t play it.
Idea 1: add uses cleartext traffic
Indicates whether the application intends to use plaintext network traffic, such as plaintext http. The default value for applications with a target API level of 27 or lower is “true.”. For applications with API level 28 or higher, the default value is “false”.
<!--Android 9.0 video playback function-->>
<application
android:usesCleartextTraffic="true"
>
</application>
After modification, some models are still not feasible.
Idea 2: Android access to x5webview
Better article links: https://www.cnblogs.com/cuichen16/p/10785945.htm
After adding, Android 10.0 or above is not feasible for higher version mobile phones
Idea 3: setmixedcontentmode
//Allow cross-domain
webSetting.setAllowFileAccessFromFileURLs(true);
webSetting.setAllowUniversalAccessFromFileURLs(true);
webSetting.setSupportMultipleWindows(true);
if (Build.VERSION.SDK_INT >= 21) {
webSetting.setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); // This sentence is crucial and can be added after
}
Finally, after adding the above three contents, the last step can be finished. If not, please continue to Baidu and keep looking for the key code.