diff options
author | Likai Ding <likaid@codeaurora.org> | 2016-05-18 13:59:06 +0800 |
---|---|---|
committer | Likai Ding <likaid@codeaurora.org> | 2016-06-03 15:34:47 +0800 |
commit | c4528995435f4b82ec104329002c1c25308a6425 (patch) | |
tree | 826cf9eea5c15eca642de02070e27c52e37f6a9e /gallerycommon | |
parent | 711aee7790ab995e61231e836bfe36a38f65cfce (diff) | |
download | android_packages_apps_Gallery2-c4528995435f4b82ec104329002c1c25308a6425.tar.gz android_packages_apps_Gallery2-c4528995435f4b82ec104329002c1c25308a6425.tar.bz2 android_packages_apps_Gallery2-c4528995435f4b82ec104329002c1c25308a6425.zip |
Gallery: MediaPlayer/Metadata wrapper
CRs-Fixed: 986672
Change-Id: Ia290c2043d0d6a01df0ff2a07d143e15078ca109
Diffstat (limited to 'gallerycommon')
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 1c3ffcd67..434771b6e 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -301,4 +301,55 @@ public class ApiHelper { invoke(setMethod, null, key, val); } } + + public static class Metadata { + public static final int PAUSE_AVAILABLE = 1; + public static final int SEEK_BACKWARD_AVAILABLE = 2; + public static final int SEEK_FORWARD_AVAILABLE = 3; + public static final int SEEK_AVAILABLE = 4; + + private static final Method hasMethod; + private static final Method getIntMethod; + private static final Method getBooleanMethod; + + static { + Class<?> klass = getClassForName("android.media.Metadata"); + hasMethod = getMethod(klass, "has", int.class); + getIntMethod = getMethod(klass, "getInt", int.class); + getBooleanMethod = getMethod(klass, "getBoolean", int.class); + } + + private Object mMetadata; + + Metadata(Object obj) { + mMetadata = obj; + } + + public boolean has(final int metadataId) { + Object obj = invoke(hasMethod, mMetadata, metadataId); + return obj == null ? false : (Boolean) obj; + } + + public int getInt(final int key) { + Object obj = invoke(getIntMethod, mMetadata, key); + return obj == null ? 0 : (Integer) obj; + } + + public boolean getBoolean(final int key) { + Object obj = invoke(getBooleanMethod, mMetadata, key); + return obj == null ? false : (Boolean) obj; + } + } + + public static class MediaPlayer { + public static final boolean METADATA_ALL = false; + public static final boolean BYPASS_METADATA_FILTER = false; + + public static Metadata getMetadata(android.media.MediaPlayer mp, + final boolean update_only, final boolean apply_filter) { + Method method = getMethod(mp.getClass(), "getMetadata", boolean.class, boolean.class); + Object obj = invoke(method, mp, update_only, apply_filter); + return obj == null ? null : new Metadata(obj); + } + } } |