problem in streaming audio from https link

前端 未结 2 2112
忘掉有多难
忘掉有多难 2021-02-11 02:18

Hi everyone I\'m a bit new to android I have developed an app which is streaming the audio from server everything was going fine until my app crashed, I debugged it and found ou

相关标签:
2条回答
  • 2021-02-11 02:59

    Android media player doesn't support HTTPS. If you provide a HTTPS URL, then the file will be downloaded.

    This "HTTPS" not supported fact is provided in android documentation.

    0 讨论(0)
  • 2021-02-11 03:02

    Just add below code before calling mediaplayer

    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
            trustStore.load(null, null);
            MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
            sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            sf.fixHttpsURLConnection();
            HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
            HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
    

    MySSLSocketFactory: https://github.com/joniks/Android-Async-HTTP/blob/master/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java

    0 讨论(0)
提交回复
热议问题