[Android] libvlc: Media: fix NPE

Thomas Guillem git at videolan.org
Thu May 28 11:20:06 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May 28 11:05:19 2015 +0200| [aa4cadd728aeff6234265462eab842e31fdc8686] | committer: Thomas Guillem

libvlc: Media: fix NPE

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=aa4cadd728aeff6234265462eab842e31fdc8686
---

 libvlc/src/org/videolan/libvlc/Media.java |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
index a15a71f..3f217f2 100644
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ b/libvlc/src/org/videolan/libvlc/Media.java
@@ -279,9 +279,14 @@ public class Media extends VLCObject {
     protected synchronized Event onEventNative(int eventType, long arg1, long arg2) {
         switch (eventType) {
         case VLCObject.Events.MediaMetaChanged:
-            int id = (int) arg1;
-            if (id >= 0 && id < Meta.MAX)
-                mNativeMetas[id] = nativeGetMeta(id);
+            // either we update all metas (if first call) or we update a specific meta
+            if (mNativeMetas == null) {
+                mNativeMetas = nativeGetMetas();
+            } else {
+                int id = (int) arg1;
+                if (id >= 0 && id < Meta.MAX)
+                    mNativeMetas[id] = nativeGetMeta(id);
+            }
             break;
         case VLCObject.Events.MediaDurationChanged:
             mDuration = nativeGetDuration();



More information about the Android mailing list