[Android] [PATCH] Media: add isBrowsable()
Thomas Guillem
thomas at gllm.fr
Tue Feb 3 15:33:46 CET 2015
---
libvlc/jni/libvlcjni-media.c | 14 ++++++++++++++
libvlc/src/org/videolan/libvlc/Media.java | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/libvlc/jni/libvlcjni-media.c b/libvlc/jni/libvlcjni-media.c
index afe1a71..aabf7cd 100644
--- a/libvlc/jni/libvlcjni-media.c
+++ b/libvlc/jni/libvlcjni-media.c
@@ -458,3 +458,17 @@ Java_org_videolan_libvlc_Media_nativeGetDuration(JNIEnv *env, jobject thiz)
return libvlc_media_get_duration(p_obj->u.p_m);
}
+
+jint
+Java_org_videolan_libvlc_Media_nativeIsBrowsable(JNIEnv *env, jobject thiz)
+{
+ vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
+
+ if (!p_obj)
+ {
+ throw_IllegalStateException(env, "can't get Media instance");
+ return 0;
+ }
+
+ return libvlc_media_is_browsable(p_obj->u.p_m);
+}
diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
index e0ff78b..843d77b 100644
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ b/libvlc/src/org/videolan/libvlc/Media.java
@@ -207,6 +207,7 @@ public final class Media extends VLCObject {
private Track mNativeTracks[] = null;
private long mDuration;
private int mState = State.NothingSpecial;
+ private int mBrowsable = -1;
/**
* Create a Media from libVLC and a mrl.
@@ -217,6 +218,7 @@ public final class Media extends VLCObject {
public Media(LibVLC libVLC, String mrl) {
nativeNewFromMrl(libVLC, mrl);
mMrl = nativeGetMrl();
+ mBrowsable = nativeIsBrowsable();
}
/**
@@ -229,6 +231,7 @@ public final class Media extends VLCObject {
throw new IllegalArgumentException("MediaList is not native");
nativeNewFromMediaList(ml, index);
mMrl = nativeGetMrl();
+ mBrowsable = nativeIsBrowsable();
}
@Override
@@ -298,6 +301,7 @@ public final class Media extends VLCObject {
throw new IllegalStateException("native metas size doesn't match");
mDuration = nativeGetDuration();
mState = nativeGetState();
+ mBrowsable = nativeIsBrowsable();
}
}
@@ -361,6 +365,18 @@ public final class Media extends VLCObject {
}
/**
+ * Get the browsable state of the media
+ *
+ * A browsable media can be a directory, a playlist, or an archive.
+ *
+ * @return 1 if the media is browsable, 0 if it's not browsable and -1 if there
+ * is no way to know if the media is browsable
+ */
+ public synchronized int isBrowsable() {
+ return mBrowsable;
+ }
+
+ /**
* Get the Track count.
*/
public synchronized int getTrackCount() {
@@ -413,4 +429,5 @@ public final class Media extends VLCObject {
private native String[] nativeGetMetas();
private native Track[] nativeGetTracks();
private native long nativeGetDuration();
+ private native int nativeIsBrowsable();
}
--
2.1.3
More information about the Android
mailing list