Search code examples
androidandroid-intentvlchttp-live-streaminguser-agent

How to call a VLC Player Intent With Stream url and User Agent


I am trying to create a intent which will call a mxplayer intent and vlc player intent . This intent will contain live video link and user agent . I added the url using intent.setData() but how to add the user agent header ?
Code :

String packagename = "com.mxtech.videoplayer.ad";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(packagename);
intent.setData(Uri.parse(now.video_url));
//add the user agent header here     
// now.user_agent contains the agent link                   
context.startActivity(intent);

Also how to do it in vlc player , I didn't find anything in their android-api with user-agent
My try for vlc:

String packagename = "org.videolan.vlc";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(packagename);
intent.setData(Uri.parse(now.video_url));

intent.putExtra("user-agent",now.user_agent);
//tried these too , doesn't work
//intent.putExtra("http-user-agent",now.user_agent);
//intent.putExtra("User-Agent",now.user_agent);
//String[] headers = {
//                            "http-user-agent", now.user_agent
//                    };
//intent.putExtra("headers",headers);
context.startActivity(intent);

Solution

  • From looking at their API I added this and it worked

    String[] headers = {
      "User-Agent", now.user_agent
    };
    intent.putExtra("headers",headers);
    context.startActivity(intent);
    

    Didn't find anything for VLC till now