0

This doesn't work when I want to play a radio with http in Android webview. It works when I play a radio with https. The strange thing is that I uploaded the url of the http stream radio with webview.loadUrl ("x"). I am using standard webview client and chrome client. Can you tell us why this is the problem? I don't see an error or warning in the logcat.

Here are the radios I want to run:

<div id="player_listing"> <div class="radio_element sub_list_item" data="https://ice31.securenetsystems.net/NOGOUM"><div class="sub_list_name">راديو نجوم اف ام</div></div><div class="radio_element sub_list_item" data="http://9090streaming.mobtada.com/9090FMEGYPT"><div class="sub_list_name">راديو 9090</div></div><div class="radio_element sub_list_item" data="http://streaming.radionomy.com/MarocMusic"><div class="sub_list_name">راديو مغربي</div></div><div class="radio_element sub_list_item" data="https://eu8.fastcast4u.com/proxy/90sfm?mp=/1"><div class="sub_list_name">راديو منوعات</div></div><div class="radio_element sub_list_item" data="http://192.99.8.192:3350/;stream.mp3"><div class="sub_list_name">راديو اغاني</div></div> </div>

https ones definitely work but http ones don't work. The website has https protocol.

I have enabled hardware usage in my Android Manifest file.

Activity:

WebView webView = findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient());
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowContentAccess(true);
webSettings.setDomStorageEnabled(true);
webView.loadUrl("https://myurl.com");
İsa C.
  • 329
  • 5
  • 16

1 Answers1

3

I had asked this question 6 months ago and found the solution. I forgot to write here and I needed it again today. I hope it helps someone else. Just add the 3 lines of code below. That is all !!! In this way, "http" and "https" stream radios running on the website will work.

    webview.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            LiveWebView.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_ALWAYS_ALLOW );
    }
İsa C.
  • 329
  • 5
  • 16
  • It works! In my case settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW was enough to make radio play – bene25 Feb 28 '23 at 21:26