I want load a third party url (http://domain1.com) on my andoird app using a WebView. This url has a iframe with other domain (http://domain2.com) that has a video player. The page load successfully, but when play the video this not load (when device's api level is < 21), and the android studio console show the next message: Blocked a frame with origin "http://domain2.com" from accessing a frame with origin "http://www.domain1.com" protocols, domains, and ports must match. When device's api level is >= 21 works fine.
WebView's code:
WebView myWebView = (WebView) view.findViewById(R.id.webView);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
myWebView.getSettings().setAllowFileAccessFromFileURLs(true);
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.loadUrl(urlWin);
if (Build.VERSION.SDK_INT >= 21) {
myWebView.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE );
} else {
// Code for Build.VERSION.SDK_INT < 21
}
How do I enable webview's mixed content on api level < 21?