I'm here to ask if there is some method for retrieving media type or encoding from VideoView in Android.

I tried this code:

    //Get the video media type
    try {
        ContentResolver cR = getContext().getContentResolver();
        String type = cR.getType(Uri.parse(url));
        Log.d("MyClass", type == null ? "???/???" : type);
    }catch (Exception e){
        Log.d("MyClass", e.getMessage());

But does not work, always return null. I need to distinguish two types of video stream visualization, MJPEG and VideoView supported type (H.264/H.265, etc...).

I Won't use libVLC because is quite expansive and compilation is only compatible with Linux machine(I work on Windows);

I want to use VideoView because is light, simple and works like a charm.

I need a function that does this:

//Get Video Type
int type = getVideoType(url); 

//Load the stream
if(type == MJPEG) 

So with the URL, I need to distinguish MJPEG to another video format. I Search on the web for a lot and I didn't find anything useful.

0 Answers