How to get URL of mp3 when it is playing

DIlshod K :

We can play mp3 files from browsers, Social Networks, Apps... I want to get URL of mp3 when it's playing. One way here is to create an extension in the browser. But in other apps we can't. Here is an example: I go to some site and open some mp3:

mp3 from sote

If you can see the music is playing and it has a URL. I want to get this URL when music starts playing. How can I do that? And how can I get URL of music which is playing in some app? Is it possible?

Roaim :

If you can see the music is playing and it has a URL. I want to get this URL when music starts playing. How can I do that?

If you are loading the website into a WebView, the easiest possible way you can get the URL by intercept the requests through WebViewClient and check if the URL contains '.mp3'. See the following example,

public class YourWebViewClient extends WebViewClient {
        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
            String url = request.getUrl().toString();
            if (url.contains(".mp3")) {
                Log.d(TAG, "MP3 url = [" + url + "]");
            }
            return super.shouldInterceptRequest(view, request);
        }
}

And how can I get URL of music which is playing in some app? Is it possible?

Yes possible but not too easy especially if you are going to get it from SSL traffic. To sniff other app's network traffic you need to perform MITM. There are a couple of apps in the play store which are doing exactly the same thing. You can look into HttpCanary app for reference. Basically you need to perform the following steps -

  1. Set up a proxy server
  2. Configure your device to pass its network traffic to that proxy server
  3. Ask the proxy server to give you the network data
  4. Analyze the network data to see if it contains 'mp3' URL

If you need to intercept https traffic, you need to generate and install an SSL certificate.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=305227&siteId=1