Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.media.MediaPlayer;
import android.text.TextUtils;
import java.lang.reflect.Method;

public class Main {
    public static final boolean METADATA_ALL = false;
    public static final boolean BYPASS_METADATA_FILTER = false;
    private static Object data;

    public static void init(MediaPlayer mp) {
        Method method = getMediadataMethod();
        method.setAccessible(true);
        try {
            data = method.invoke(mp, METADATA_ALL, BYPASS_METADATA_FILTER);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            data = null;
        } catch (Exception e) {
            data = null;
        }
    }

    private static Method getMediadataMethod() {
        Method[] methods = MediaPlayer.class.getDeclaredMethods();
        for (Method method : methods) {
            if (TextUtils.equals(method.getName(), "getMetadata")) {
                return method;
            }
        }
        return null;
    }
}