[Android] medialib: Use new setProgress API
Hugo Beauzée-Luyssen
git at videolan.org
Tue Nov 24 09:39:49 CET 2020
vlc-android | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Jun 23 16:03:24 2020 +0200| [d6418bfbeb325e46d1a2158b5219e7414ac32df4] | committer: Hugo Beauzée-Luyssen
medialib: Use new setProgress API
> https://code.videolan.org/videolan/vlc-android/commit/d6418bfbeb325e46d1a2158b5219e7414ac32df4
---
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 2 +-
buildsystem/compile-medialibrary.sh | 2 +-
medialibrary/jni/AndroidMediaLibrary.cpp | 4 ++--
medialibrary/jni/AndroidMediaLibrary.h | 2 +-
medialibrary/jni/medialibrary.cpp | 6 +++---
medialibrary/jni/utils.cpp | 5 +----
medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java | 6 +++---
.../src/org/videolan/medialibrary/interfaces/Medialibrary.java | 2 +-
.../src/org/videolan/medialibrary/stubs/StubMedialibrary.java | 4 ++--
9 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index c85d01f7b..be3bc2cc7 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -871,7 +871,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (internalMedia != null) id = internalMedia.id
}
}
- if (id != 0L) medialibrary.increasePlayCount(id)
+ if (id != 0L) medialibrary.setProgress(id, 1.0f)
}
}
diff --git a/buildsystem/compile-medialibrary.sh b/buildsystem/compile-medialibrary.sh
index 865d70f08..5279d510d 100755
--- a/buildsystem/compile-medialibrary.sh
+++ b/buildsystem/compile-medialibrary.sh
@@ -4,7 +4,7 @@
# ARGUMENTS #
#############
-MEDIALIBRARY_HASH=03031cd1605ab07f61738b71a782831ea31c36b5
+MEDIALIBRARY_HASH=1755e7abfa80f53129050c9d39f5494025a9a854
while [ $# -gt 0 ]; do
case $1 in
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 7ee8b44b8..7c4b6c7a2 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -177,11 +177,11 @@ AndroidMediaLibrary::forceRescan()
}
bool
-AndroidMediaLibrary::increasePlayCount(int64_t mediaId)
+AndroidMediaLibrary::setProgress(int64_t mediaId, float progress)
{
auto media = p_ml->media(mediaId);
if (media != nullptr)
- return media->increasePlayCount();
+ return media->setProgress( progress );
return false;
}
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index 29d65aa1f..527f6afa3 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -51,7 +51,7 @@ public:
void reload( const std::string& entryPoint );
void forceParserRetry();
void forceRescan();
- bool increasePlayCount(int64_t mediaId);
+ bool setProgress(int64_t mediaId, float progress);
void removeMediaFromHistory(int64_t mediaId);
/* History */
std::vector<medialibrary::MediaPtr> lastMediaPlayed();
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 9d92d1f18..a83adcc52 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -240,9 +240,9 @@ forceRescan(JNIEnv* env, jobject thiz)
}
jboolean
-increasePlayCount(JNIEnv* env, jobject thiz, jlong id)
+setProgress(JNIEnv* env, jobject thiz, jlong id, jfloat progress)
{
- return MediaLibrary_getInstance(env, thiz)->increasePlayCount((int64_t)id);
+ return MediaLibrary_getInstance(env, thiz)->setProgress((int64_t)id, (float)progress);
}
void
@@ -2119,7 +2119,7 @@ static JNINativeMethod methods[] = {
{"nativeReload", "(Ljava/lang/String;)V", (void*)reloadEntryPoint },
{"nativeForceParserRetry", "()V", (void*)forceParserRetry },
{"nativeForceRescan", "()V", (void*)forceRescan },
- {"nativeIncreasePlayCount", "(J)Z", (void*)increasePlayCount },
+ {"nativeSetProgress", "(JF)Z", (void*)setProgress },
{"nativeSetMediaUpdatedCbFlag", "(I)V", (void*)setMediaUpdatedCbFlag },
{"nativeSetMediaAddedCbFlag", "(I)V", (void*)setMediaAddedCbFlag },
{"nativePlaylistCreate", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/Playlist;", (void*)playlistCreate },
diff --git a/medialibrary/jni/utils.cpp b/medialibrary/jni/utils.cpp
index 6a2cdaa51..5de7d0b59 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -62,10 +62,7 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
unsigned int width = hasVideoTracks ? videoTracks.at(0)->width() : 0;
unsigned int height = hasVideoTracks ? videoTracks.at(0)->height() : 0;
int64_t duration = mediaPtr->duration();
- const medialibrary::IMetadata& progressMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Progress );
- int64_t progress = progressMeta.isSet() ? progressMeta.asInt() : 0;
- // workaround to convert legacy percentage progress
- if (progress != 0 && progress < 100) progress = duration * ( progress / 100.0 );
+ const float progress = mediaPtr->progress() * duration;
const medialibrary::IMetadata& seenMeta = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Seen );
int64_t seen = seenMeta.isSet() ? seenMeta.asInt() : 0;
diff --git a/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java b/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
index 0eca3dc92..0ea70f0db 100644
--- a/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
+++ b/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
@@ -466,8 +466,8 @@ public class MedialibraryImpl extends Medialibrary {
return mIsInitiated ? nativeGetFoldersCount(type) : 0;
}
- public boolean increasePlayCount(long mediaId) {
- return mIsInitiated && mediaId > 0 && nativeIncreasePlayCount(mediaId);
+ public boolean setProgress(long mediaId, float progress) {
+ return mIsInitiated && mediaId > 0 && nativeSetProgress(mediaId, progress);
}
// If media is not in ML, find it with its path
@@ -641,7 +641,7 @@ public class MedialibraryImpl extends Medialibrary {
private native void nativeReload(String entryPoint);
private native void nativeForceParserRetry();
private native void nativeForceRescan();
- private native boolean nativeIncreasePlayCount(long mediaId);
+ private native boolean nativeSetProgress(long mediaId, float progress);
private native void nativeSetMediaUpdatedCbFlag(int flags);
private native void nativeSetMediaAddedCbFlag(int flags);
private native SearchAggregate nativeSearch(String query);
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
index 3b49d01be..6e24ebcbc 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
@@ -747,7 +747,7 @@ abstract public class Medialibrary {
abstract public MediaWrapper addStream(String mrl, String title);
abstract public Folder[] getFolders(int type, int sort, boolean desc, int nbItems, int offset);
abstract public int getFoldersCount(int type);
- abstract public boolean increasePlayCount(long mediaId);
+ abstract public boolean setProgress(long mediaId, float progress);
abstract public SearchAggregate search(String query);
abstract public MediaWrapper[] searchMedia(String query);
abstract public MediaWrapper[] searchMedia(String query, int sort, boolean desc, int nbItems, int offset);
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
index a2ad387a2..ad1b1d805 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
@@ -389,7 +389,7 @@ public class StubMedialibrary extends Medialibrary {
media = addStream(mrl, title);
}
dt.mHistory.add(media);
- increasePlayCount(media.getId());
+ setProgress(media.getId(), 1.0f);
return true;
}
@@ -482,7 +482,7 @@ public class StubMedialibrary extends Medialibrary {
public void requestThumbnail(long id) {}
- public boolean increasePlayCount(long mediaId) {
+ public boolean setProgress(long mediaId, float progress) {
for (int i = 0; i < dt.mVideoMediaWrappers.size(); i++) {
MediaWrapper media = dt.mVideoMediaWrappers.get(i);
if (media.getId() == mediaId) {
More information about the Android
mailing list