[Android] MediaLibrary: Update to recent API changes

Hugo Beauzée-Luyssen git at videolan.org
Fri Dec 30 15:33:47 CET 2016


vlc-android | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Dec 30 15:33:26 2016 +0100| [6fe3ecbb6ca13b757ab0a425b941d69de3673a9c] | committer: Hugo Beauzée-Luyssen

MediaLibrary: Update to recent API changes

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

 medialibrary/jni/AndroidMediaLibrary.cpp | 11 +++++++++--
 medialibrary/jni/AndroidMediaLibrary.h   |  1 -
 medialibrary/jni/utils.cpp               |  7 ++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 756dd19..1eb4b0d 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -175,9 +175,16 @@ AndroidMediaLibrary::lastMediaPlayed()
 }
 
 bool
-AndroidMediaLibrary::addToHistory( const std::string& mrl, const std::string& title )
+AndroidMediaLibrary::addToHistory( const std::string& mrl, const std::string& )
 {
-    return p_ml->addToHistory(mrl, title);
+    auto media = p_ml->media( mrl );
+    if ( media == nullptr )
+    {
+        media = p_ml->addMedia( mrl );
+        if ( media == nullptr )
+            return false;
+    }
+    return p_ml->addToStreamHistory( media );
 }
 
 std::vector<medialibrary::HistoryPtr>
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index eb689a3..141dabb 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -15,7 +15,6 @@
 #include <medialibrary/IAlbum.h>
 #include <medialibrary/IArtist.h>
 #include <medialibrary/IGenre.h>
-#include <medialibrary/IHistoryEntry.h>
 #include <medialibrary/IPlaylist.h>
 #include <medialibrary/IFolder.h>
 #include <medialibrary/Types.h>
diff --git a/medialibrary/jni/utils.cpp b/medialibrary/jni/utils.cpp
index a985322..bad1cd5 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -208,10 +208,11 @@ convertSearchAggregateObject(JNIEnv* env, fields *fields, medialibrary::SearchAg
 jobject
 convertHistoryItemObject(JNIEnv* env, fields *fields, medialibrary::HistoryPtr const& historyPtr)
 {
-    jstring mrl = env->NewStringUTF(historyPtr->mrl().c_str());
-    jstring title = env->NewStringUTF(historyPtr->title().c_str());
+    auto media = historyPtr->media().get();
+    jstring mrl = env->NewStringUTF(media->files()[0]->mrl().c_str());
+    jstring title = env->NewStringUTF(media->title().c_str());
     jobject item = env->NewObject(fields->HistoryItem.clazz, fields->HistoryItem.initID, mrl, title,
-                          (jlong) historyPtr->insertionDate(), (jboolean) historyPtr->isFavorite());
+                          (jlong) historyPtr->insertionDate(), (jboolean) false);
     env->DeleteLocalRef(mrl);
     return item;
 }



More information about the Android mailing list