[Android] Implement the ML removeThumbnail API and use it when media are converted to external
Nicolas Pomepuy
git at videolan.org
Thu Jun 10 11:15:41 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jun 8 14:09:50 2021 +0200| [5c986130b590638e11c6c6346a6f7c4344b8dc81] | committer: Nicolas Pomepuy
Implement the ML removeThumbnail API and use it when media are converted to external
Fixes #2049
> https://code.videolan.org/videolan/vlc-android/commit/5c986130b590638e11c6c6346a6f7c4344b8dc81
---
.../src/org/videolan/vlc/viewmodels/CallBackDelegate.kt | 2 +-
buildsystem/compile-medialibrary.sh | 2 +-
medialibrary/jni/medialibrary.cpp | 10 ++++++++++
.../videolan/medialibrary/interfaces/media/MediaWrapper.java | 1 +
.../src/org/videolan/medialibrary/media/MediaWrapperImpl.java | 7 +++++++
.../src/org/videolan/medialibrary/stubs/StubMediaWrapper.java | 2 ++
6 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/CallBackDelegate.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/CallBackDelegate.kt
index 115b0b5a0..70697f550 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/CallBackDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/CallBackDelegate.kt
@@ -88,7 +88,7 @@ class CallBackDelegate : ICallBackHandler,
val file = File(it.absolutePath + Medialibrary.MEDIALIB_FOLDER_NAME + "/$mediaId.jpg")
if (file.exists()) {
val media = medialibrary.getMedia(mediaId)
- //todo tell ML to remove the thumb in DB
+ media.removeThumbnail()
}
FileUtils.deleteFile(file)
}
diff --git a/buildsystem/compile-medialibrary.sh b/buildsystem/compile-medialibrary.sh
index 93b3033a2..42ee57564 100755
--- a/buildsystem/compile-medialibrary.sh
+++ b/buildsystem/compile-medialibrary.sh
@@ -4,7 +4,7 @@
# ARGUMENTS #
#############
-MEDIALIBRARY_HASH=48da0cd521554be2e16abc90f65fcf105af314c8
+MEDIALIBRARY_HASH=14405d6c7daabf55bc1939c89567f2dd16fab2b4
while [ $# -gt 0 ]; do
case $1 in
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 5ff62945f..309b3dfb6 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -1521,6 +1521,15 @@ setMediaThumbnail(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id, jst
env->ReleaseStringUTFChars(mrl, char_mrl);
}
+jboolean
+removeMediaThumbnail(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id)
+{
+ AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
+ medialibrary::MediaPtr media = aml->media(id);
+ if (media == nullptr) return false;
+ return media->removeThumbnail(medialibrary::ThumbnailSizeType::Thumbnail);
+}
+
void
setMediaTitle(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id, jstring title)
{
@@ -2107,6 +2116,7 @@ static JNINativeMethod media_methods[] = {
{"nativeSetMediaStringMetadata", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JILjava/lang/String;)V", (void*)setMediaStringMetadata },
{"nativeSetMediaLongMetadata", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JIJ)V", (void*)setMediaLongMetadata },
{"nativeSetMediaThumbnail", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JLjava/lang/String;)V", (void*)setMediaThumbnail },
+ {"nativeRemoveMediaThumbnail", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;J)Z", (void*)removeMediaThumbnail },
{"nativeSetMediaTitle", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JLjava/lang/String;)V", (void*)setMediaTitle },
{"nativeRemoveFromHistory", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;J)Z", (void*)removeMediaFromHistory },
{"nativeRequestThumbnail", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JIIIF)V", (void*)requestThumbnail },
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
index 7ec43f31a..c9093e578 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/MediaWrapper.java
@@ -133,6 +133,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
public abstract boolean setLongMeta(int metaDataType, long metaDataValue);
public abstract boolean setStringMeta(int metaDataType, String metaDataValue);
public abstract void setThumbnail(String mrl);
+ public abstract void removeThumbnail();
public abstract void requestThumbnail(int width, float position);
public abstract void requestBanner(int width, float position);
public abstract boolean removeFromHistory();
diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapperImpl.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapperImpl.java
index c58303daf..b5de07ede 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapperImpl.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapperImpl.java
@@ -271,6 +271,12 @@ public class MediaWrapperImpl extends MediaWrapper {
if (mId != 0 && ml.isInitiated()) nativeSetMediaThumbnail(ml, mId, Tools.encodeVLCMrl(mrl));
}
+ public void removeThumbnail() {
+ if (mId == 0L) return;
+ final Medialibrary ml = Medialibrary.getInstance();
+ if (mId != 0 && ml.isInitiated()) nativeRemoveMediaThumbnail(ml, mId);
+ }
+
public void requestThumbnail(int width, float position) {
if (mId == 0L) return;
final Medialibrary ml = Medialibrary.getInstance();
@@ -290,6 +296,7 @@ public class MediaWrapperImpl extends MediaWrapper {
private native void nativeSetMediaTitle(Medialibrary ml, long id, String name);
private native boolean nativeRemoveFromHistory(Medialibrary ml, long id);
private native void nativeSetMediaThumbnail(Medialibrary ml, long id, String mrl);
+ private native boolean nativeRemoveMediaThumbnail(Medialibrary ml, long id);
private native void nativeRequestThumbnail(Medialibrary ml, long mediaId, int type, int width, int height, float position);
private native Bookmark[] nativeGetBookmarks(Medialibrary ml, long id);
private native Bookmark nativeAddBookmark(Medialibrary ml, long id, long time);
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubMediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubMediaWrapper.java
index d2bf98c63..0f539dac0 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubMediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubMediaWrapper.java
@@ -103,6 +103,8 @@ public class StubMediaWrapper extends MediaWrapper {
public void setThumbnail(String mrl) {}
+ public void removeThumbnail() {}
+
@Override
public void requestThumbnail(int width, float position) {}
More information about the Android
mailing list