[Android] Album/Artist/Genre getters by id
Geoffrey Métais
git at videolan.org
Wed Nov 9 15:37:58 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 9 15:27:34 2016 +0100| [80057f09a903ccb0b72694052d60491afab9c1bf] | committer: Geoffrey Métais
Album/Artist/Genre getters by id
> https://code.videolan.org/videolan/vlc-android/commit/80057f09a903ccb0b72694052d60491afab9c1bf
---
medialibrary/jni/AndroidMediaLibrary.cpp | 18 +++++++++++++++
medialibrary/jni/AndroidMediaLibrary.h | 3 +++
medialibrary/jni/medialibrary.cpp | 27 ++++++++++++++++++++++
.../org/videolan/medialibrary/Medialibrary.java | 15 ++++++++++++
vlc-android/build.gradle | 2 +-
5 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index d0044aa..cd6165b 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -192,18 +192,36 @@ AndroidMediaLibrary::albums()
return p_ml->albums();
}
+medialibrary::AlbumPtr
+AndroidMediaLibrary::album(int64_t albumId)
+{
+ return p_ml->album(albumId);
+}
+
std::vector<medialibrary::ArtistPtr>
AndroidMediaLibrary::artists()
{
return p_ml->artists();
}
+medialibrary::ArtistPtr
+AndroidMediaLibrary::artist(int64_t artistId)
+{
+ return p_ml->artist(artistId);
+}
+
std::vector<medialibrary::GenrePtr>
AndroidMediaLibrary::genres()
{
return p_ml->genres();
}
+medialibrary::GenrePtr
+AndroidMediaLibrary::genre(int64_t genreId)
+{
+ return p_ml->genre(genreId);
+}
+
std::vector<medialibrary::PlaylistPtr>
AndroidMediaLibrary::playlists()
{
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index 5383785..19ee7d2 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -48,8 +48,11 @@ public:
std::vector<medialibrary::MediaPtr> videoFiles( medialibrary::SortingCriteria sort = medialibrary::SortingCriteria::Default, bool desc = false );
std::vector<medialibrary::MediaPtr> audioFiles( medialibrary::SortingCriteria sort = medialibrary::SortingCriteria::Default, bool desc = false );
std::vector<medialibrary::AlbumPtr> albums();
+ medialibrary::AlbumPtr album(int64_t albumId);
std::vector<medialibrary::ArtistPtr> artists();
+ medialibrary::ArtistPtr artist(int64_t artistId);
std::vector<medialibrary::GenrePtr> genres();
+ medialibrary::GenrePtr genre(int64_t genreId);
std::vector<medialibrary::PlaylistPtr> playlists();
medialibrary::PlaylistPtr playlist( int64_t playlistId );
medialibrary::PlaylistPtr PlaylistCreate( const std::string &name );
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index c965430..51046d9 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -245,6 +245,14 @@ getAlbums(JNIEnv* env, jobject thiz)
return albumRefs;
}
+jobject
+getAlbum(JNIEnv* env, jobject thiz, jlong id)
+{
+ AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
+ medialibrary::AlbumPtr album = aml->album(id);
+ return album != nullptr ? convertAlbumObject(env, &ml_fields, album) : nullptr;
+}
+
jobjectArray
getArtists(JNIEnv* env, jobject thiz)
{
@@ -260,6 +268,14 @@ getArtists(JNIEnv* env, jobject thiz)
return artistRefs;
}
+jobject
+getArtist(JNIEnv* env, jobject thiz, jlong id)
+{
+ AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
+ medialibrary::ArtistPtr artist = aml->artist(id);
+ return artist != nullptr ? convertArtistObject(env, &ml_fields, artist) : nullptr;
+}
+
jobjectArray
getGenres(JNIEnv* env, jobject thiz)
{
@@ -275,6 +291,14 @@ getGenres(JNIEnv* env, jobject thiz)
return genreRefs;
}
+jobject
+getGenre(JNIEnv* env, jobject thiz, jlong id)
+{
+ AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
+ medialibrary::GenrePtr genre = aml->genre(id);
+ return genre != nullptr ? convertGenreObject(env, &ml_fields, genre) : nullptr;
+}
+
jobjectArray
getPlaylists(JNIEnv* env, jobject thiz)
{
@@ -503,8 +527,11 @@ static JNINativeMethod methods[] = {
{"nativeGetVideoCount", "()I", (void*)getVideoCount },
{"nativeGetAudioCount", "()I", (void*)getAudioCount },
{"nativeGetAlbums", "()[Lorg/videolan/medialibrary/media/Album;", (void*)getAlbums },
+ {"nativeGetAlbum", "(J)Lorg/videolan/medialibrary/media/Album;", (void*)getAlbum },
{"nativeGetArtists", "()[Lorg/videolan/medialibrary/media/Artist;", (void*)getArtists },
+ {"nativeGetArtist", "(J)Lorg/videolan/medialibrary/media/Artist;", (void*)getArtist },
{"nativeGetGenres", "()[Lorg/videolan/medialibrary/media/Genre;", (void*)getGenres },
+ {"nativeGetGenre", "(J)Lorg/videolan/medialibrary/media/Genre;", (void*)getGenre },
{"nativeGetPlaylists", "()[Lorg/videolan/medialibrary/media/Playlist;", (void*)getPlaylists },
{"nativeGetPlaylist", "(J)Lorg/videolan/medialibrary/media/Playlist;", (void*)getPlaylist },
{"nativeIsWorking", "()Z", (void*)isWorking },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 464a8ab..f438321 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -138,14 +138,26 @@ public class Medialibrary {
return mIsInitiated ? nativeGetAlbums() : new Album[0];
}
+ public Album getAlbum(long albumId) {
+ return mIsInitiated ? nativeGetAlbum(albumId) : null;
+ }
+
public Artist[] getArtists() {
return mIsInitiated ? nativeGetArtists() : new Artist[0];
}
+ public Artist getArtist(long artistId) {
+ return mIsInitiated ? nativeGetArtist(artistId) : null;
+ }
+
public Genre[] getGenres() {
return mIsInitiated ? nativeGetGenres() : new Genre[0];
}
+ public Genre getGenre(long genreId) {
+ return mIsInitiated ? nativeGetGenre(genreId) : null;
+ }
+
public Playlist[] getPlaylists() {
return mIsInitiated ? nativeGetPlaylists() : new Playlist[0];
}
@@ -387,8 +399,11 @@ public class Medialibrary {
private native int nativeGetAudioCount();
private native boolean nativeIsWorking();
private native Album[] nativeGetAlbums();
+ private native Album nativeGetAlbum(long albumtId);
private native Artist[] nativeGetArtists();
+ private native Artist nativeGetArtist(long artistId);
private native Genre[] nativeGetGenres();
+ private native Genre nativeGetGenre(long genreId);
private native Playlist[] nativeGetPlaylists();
private native Playlist nativeGetPlaylist(long playlistId);
private native Playlist nativePlaylistCreate(String name);
diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index f620979..aa90adf 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -195,6 +195,7 @@ android {
dependencies {
compile project(':libvlc')
+ compile project(':medialibrary')
compile project(':api')
compile project(':axmlrpc')
compile 'com.android.support:appcompat-v7:24.2.1'
@@ -206,7 +207,6 @@ dependencies {
compile 'com.android.support:leanback-v17:24.2.1'
compile 'com.android.support:preference-leanback-v17:24.2.1'
testCompile 'junit:junit:4.12'
- compile project(':medialibrary')
}
def buildTime() {
More information about the Android
mailing list