Hello guys , am new to Android Development, I've created many test apps for learning, using webview and lists and creating multiple activities,
I have an application that get URL with JSON data contain url with streaming video and when click on button open VLC with URL provided.
JSon FILE

[{"ch":"http://www.examplevideo.com/video.mp4"},{"ch":"http://www.examplevideo.com/video2.mp4"}]

Dani AI

Generated

Nice question, and good call following peter_budo’s advice to use an ACTION_VIEW intent and check for VLC first. To build on that thread and avoid crashes, target VLC if present but gracefully fall back to any installed player. You also do not need any VLC .jar; you are handing the URL off to the VLC app, not embedding its engine in your app (as peter_budo noted).

Here is a compact pattern that plays a streaming URL from your JSON and handles the VLC-not-installed case cleanly:

// Assume you already parsed your JSON and have a String videoUrl
Uri uri = Uri.parse(videoUrl);

// Base VIEW intent for any video player
Intent play = new Intent(Intent.ACTION_VIEW)
        .setDataAndType(uri, "video/*")
        .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

PackageManager pm = getPackageManager();

// Prefer VLC if installed
final String VLC_PACKAGE = "org.videolan.vlc";
try {
    pm.getPackageInfo(VLC_PACKAGE, 0);
    play.setPackage(VLC_PACKAGE);          // target VLC specifically
    if (play.resolveActivity(pm) != null) {
        startActivity(play);
        return;
    }
} catch (PackageManager.NameNotFoundException ignore) { /* VLC not installed */ }

// Fallback: let user pick another player (or guide them to install VLC)
startActivity(Intent.createChooser(play, "Play with"));

Practical tips:

  • Use a broad MIME like video/* so HLS (.m3u8) and other containers are handled without you guessing the exact type.
  • Do not hardcode legacy beta package IDs; the release package is what users install from the store.
  • Avoid setComponent(...) to internal VLC activities; let intent filters handle routing so your code keeps working across VLC updates and Android versions.
  • If you later support local files (not just http/https), expose them via FileProvider and keep FLAG_GRANT_READ_URI_PERMISSION.

Recommended Answers

All 8 Replies

There is no official API yet as this is still under development. However according to VLC forum you just need to do this

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("org.videolan.vlc.betav7neon"); // Use org.videolan.vlc for nightly builds
intent.setDataAndType(Uri.parse(""), "application/mp4");
startActivity(intent);

My suggestion would be to check first for vlc in PackageManager to avoid crash if app not installed. You can follow discussion on intent here

Thanks @PETER BUDO , my first problem is I can't add VLC lib to my project because I need to compile it first using linux which I don't have :(, is there any .jar file so I cant import it easily?.

You are misunderstanding concept. This is not jar library that you add to your project, but rather expectation that user has this application installed on device and thereore with help of Android intent you can say "load this url with following application of this package name"

commented: thanks +2

I'll try this when I get to home :P, thanks.

thanks buddy works like a charm after added check for if VLC installed .
problem solved.

Glad to hear that!

peter budo thanks alot, it worked for me as well

@Hanif1993 you welcome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.