[Android] Add medialibrary initialization checks

Geoffrey Métais git at videolan.org
Wed Jul 5 17:23:02 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul  5 16:21:23 2017 +0200| [cb34f07797fe9358e28e86497e9012aa637ebd97] | committer: Geoffrey Métais

Add medialibrary initialization checks

> https://code.videolan.org/videolan/vlc-android/commit/cb34f07797fe9358e28e86497e9012aa637ebd97
---

 .../src/org/videolan/medialibrary/media/MediaWrapper.java         | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
index 8eb1b0357..f3196bb32 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
@@ -574,20 +574,20 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
     }
 
     public long getMetaLong(Medialibrary ml, int metaDataType) {
-        return mId == 0 ? 0L : nativeGetMediaLongMetadata(ml, mId, metaDataType);
+        return mId == 0 || !ml.isInitiated() ? 0L : nativeGetMediaLongMetadata(ml, mId, metaDataType);
     }
     public String getMetaString(Medialibrary ml, int metaDataType) {
-        return mId == 0 ? null : nativeGetMediaStringMetadata(ml, mId, metaDataType);
+        return mId == 0 || !ml.isInitiated() ? null : nativeGetMediaStringMetadata(ml, mId, metaDataType);
     }
 
     public boolean setLongMeta(Medialibrary ml, int metaDataType, long metadataValue) {
-        if (mId != 0)
+        if (mId != 0 && ml.isInitiated())
             nativeSetMediaLongMetadata(ml, mId, metaDataType, metadataValue);
         return mId != 0;
     }
 
     public boolean setStringMeta(Medialibrary ml, int metaDataType, String metadataValue) {
-        if (mId != 0)
+        if (mId != 0 && ml.isInitiated())
             nativeSetMediaStringMetadata(ml, mId, metaDataType, metadataValue);
         return mId != 0;
     }



More information about the Android mailing list