[Android] [PATCH] AlbumArtist tag support
Jean-Baptiste Kempf
jb at videolan.org
Wed Dec 10 22:39:04 CET 2014
LGTM if tested
On 10 Dec, Geoffrey Métais wrote :
> ---
> libvlc/jni/libvlcjni-track.c | 1 +
> libvlc/src/org/videolan/libvlc/Media.java | 25 ++++++++-
> libvlc/src/org/videolan/libvlc/TrackInfo.java | 1 +
> .../src/org/videolan/vlc/MediaDatabase.java | 61 ++++++++++++----------
> vlc-android/src/org/videolan/vlc/MediaGroup.java | 1 +
> .../vlc/gui/audio/AudioAlbumsSongsFragment.java | 2 +-
> .../vlc/gui/audio/AudioBrowserListAdapter.java | 4 +-
> .../videolan/vlc/gui/audio/MediaComparators.java | 2 +-
> 8 files changed, 64 insertions(+), 33 deletions(-)
>
> diff --git a/libvlc/jni/libvlcjni-track.c b/libvlc/jni/libvlcjni-track.c
> index 3b68564..398242b 100644
> --- a/libvlc/jni/libvlcjni-track.c
> +++ b/libvlc/jni/libvlcjni-track.c
> @@ -156,6 +156,7 @@ jobjectArray read_track_info_internal(JNIEnv *env, jobject thiz, libvlc_media_t*
> setString(env, item, "ArtworkURL", libvlc_media_get_meta(p_m, libvlc_meta_ArtworkURL));
> setString(env, item, "NowPlaying", libvlc_media_get_meta(p_m, libvlc_meta_NowPlaying));
> setString(env, item, "TrackNumber", libvlc_media_get_meta(p_m, libvlc_meta_TrackNumber));
> + setString(env, item, "AlbumArtist", libvlc_media_get_meta(p_m, libvlc_meta_AlbumArtist));
> continue;
> }
>
> diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
> index 41c61e7..4e333be 100644
> --- a/libvlc/src/org/videolan/libvlc/Media.java
> +++ b/libvlc/src/org/videolan/libvlc/Media.java
> @@ -102,6 +102,7 @@ public class Media implements Comparable<Media> {
> private String mCopyright;
> private String mAlbum;
> private int mTrackNumber;
> + private String mAlbumArtist;
> private String mDescription;
> private String mRating;
> private String mDate;
> @@ -182,6 +183,7 @@ public class Media implements Comparable<Media> {
> mArtist = getValueWrapper(track.Artist, UnknownStringType.Artist).trim();
> mAlbum = getValueWrapper(track.Album, UnknownStringType.Album).trim();
> mGenre = getValueWrapper(track.Genre, UnknownStringType.Genre).trim();
> + mAlbumArtist = getValueWrapper(track.AlbumArtist, UnknownStringType.AlbumArtist).trim();
> mArtworkURL = track.ArtworkURL;
> mNowPlaying = track.NowPlaying;
> if (!TextUtils.isEmpty(track.TrackNumber)) {
> @@ -212,7 +214,7 @@ public class Media implements Comparable<Media> {
> }
>
> public Media(String location, long time, long length, int type,
> - Bitmap picture, String title, String artist, String genre, String album,
> + Bitmap picture, String title, String artist, String genre, String album, String albumArtist,
> int width, int height, String artworkURL, int audio, int spu, int trackNumber) {
> mLocation = location;
> mFilename = null;
> @@ -229,11 +231,12 @@ public class Media implements Comparable<Media> {
> mArtist = getValueWrapper(artist, UnknownStringType.Artist);
> mGenre = getValueWrapper(genre, UnknownStringType.Genre);
> mAlbum = getValueWrapper(album, UnknownStringType.Album);
> + mAlbumArtist = getValueWrapper(albumArtist, UnknownStringType.AlbumArtist);
> mArtworkURL = artworkURL;
> mTrackNumber = trackNumber;
> }
>
> - private enum UnknownStringType { Artist , Genre, Album };
> + private enum UnknownStringType { Artist , Genre, Album, AlbumArtist };
> /**
> * Uses introspection to read VLC l10n databases, so that we can sever the
> * hard-coded dependency gracefully for 3rd party libvlc apps while still
> @@ -260,6 +263,9 @@ public class Media implements Comparable<Media> {
> case Genre:
> value = (Integer)stringClass.getField("unknown_genre").get(null);
> break;
> + case AlbumArtist:
> + value = (Integer)stringClass.getField("unknown_artist").get(null);
> + break;
> case Artist:
> default:
> value = (Integer)stringClass.getField("unknown_artist").get(null);
> @@ -412,10 +418,21 @@ public class Media implements Comparable<Media> {
> : "";
> }
>
> + public String getReferenceArtist() {
> + if (isAlbumArtistUnknown())
> + return mArtist;
> + else
> + return mAlbumArtist;
> + }
> +
> public String getArtist() {
> return mArtist;
> }
>
> + public Boolean isAlbumArtistUnknown() {
> + return (mAlbumArtist.equals(getValueWrapper(null, UnknownStringType.AlbumArtist)));
> + }
> +
> public Boolean isArtistUnknown() {
> return (mArtist.equals(getValueWrapper(null, UnknownStringType.Artist)));
> }
> @@ -437,6 +454,10 @@ public class Media implements Comparable<Media> {
> return mAlbum;
> }
>
> + public String getAlbumArtist() {
> + return mAlbumArtist;
> + }
> +
> public Boolean isAlbumUnknown() {
> return (mAlbum.equals(getValueWrapper(null, UnknownStringType.Album)));
> }
> diff --git a/libvlc/src/org/videolan/libvlc/TrackInfo.java b/libvlc/src/org/videolan/libvlc/TrackInfo.java
> index 49a4f06..0ef1ab9 100644
> --- a/libvlc/src/org/videolan/libvlc/TrackInfo.java
> +++ b/libvlc/src/org/videolan/libvlc/TrackInfo.java
> @@ -52,4 +52,5 @@ public class TrackInfo {
> public String ArtworkURL;
> public String NowPlaying;
> public String TrackNumber;
> + public String AlbumArtist;
> }
> diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
> index 48231c4..9537c9f 100644
> --- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
> +++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
> @@ -51,7 +51,7 @@ public class MediaDatabase {
>
> private SQLiteDatabase mDb;
> private final String DB_NAME = "vlc_database";
> - private final int DB_VERSION = 9;
> + private final int DB_VERSION = 10;
> private final int CHUNK_SIZE = 50;
>
> private final String DIR_TABLE_NAME = "directories_table";
> @@ -67,6 +67,7 @@ public class MediaDatabase {
> private final String MEDIA_ARTIST = "artist";
> private final String MEDIA_GENRE = "genre";
> private final String MEDIA_ALBUM = "album";
> + private final String MEDIA_ALBUMARTIST = "albumartist";
> private final String MEDIA_WIDTH = "width";
> private final String MEDIA_HEIGHT = "height";
> private final String MEDIA_ARTWORKURL = "artwork_url";
> @@ -90,8 +91,8 @@ public class MediaDatabase {
> public enum mediaColumn {
> MEDIA_TABLE_NAME, MEDIA_PATH, MEDIA_TIME, MEDIA_LENGTH,
> MEDIA_TYPE, MEDIA_PICTURE, MEDIA_TITLE, MEDIA_ARTIST, MEDIA_GENRE, MEDIA_ALBUM,
> - MEDIA_WIDTH, MEDIA_HEIGHT, MEDIA_ARTWORKURL, MEDIA_AUDIOTRACK, MEDIA_SPUTRACK,
> - MEDIA_TRACKNUMBER
> + MEDIA_ALBUMARTIST, MEDIA_WIDTH, MEDIA_HEIGHT, MEDIA_ARTWORKURL, MEDIA_AUDIOTRACK,
> + MEDIA_SPUTRACK, MEDIA_TRACKNUMBER
> }
>
> /**
> @@ -166,6 +167,7 @@ public class MediaDatabase {
> + MEDIA_ARTIST + " TEXT, "
> + MEDIA_GENRE + " TEXT, "
> + MEDIA_ALBUM + " TEXT, "
> + + MEDIA_ALBUMARTIST + " TEXT, "
> + MEDIA_WIDTH + " INTEGER, "
> + MEDIA_HEIGHT + " INTEGER, "
> + MEDIA_ARTWORKURL + " TEXT, "
> @@ -452,6 +454,7 @@ public class MediaDatabase {
> values.put(MEDIA_ARTIST, media.getArtist());
> values.put(MEDIA_GENRE, media.getGenre());
> values.put(MEDIA_ALBUM, media.getAlbum());
> + values.put(MEDIA_ALBUMARTIST, media.getAlbumArtist());
> values.put(MEDIA_WIDTH, media.getWidth());
> values.put(MEDIA_HEIGHT, media.getHeight());
> values.put(MEDIA_ARTWORKURL, media.getArtworkURL());
> @@ -544,7 +547,7 @@ public class MediaDatabase {
> do {
> count = 0;
> cursor = mDb.rawQuery(String.format(Locale.US,
> - "SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s LIMIT %d OFFSET %d",
> + "SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s LIMIT %d OFFSET %d",
> MEDIA_TIME, //0 long
> MEDIA_LENGTH, //1 long
> MEDIA_TYPE, //2 int
> @@ -552,13 +555,14 @@ public class MediaDatabase {
> MEDIA_ARTIST, //4 string
> MEDIA_GENRE, //5 string
> MEDIA_ALBUM, //6 string
> - MEDIA_WIDTH, //7 int
> - MEDIA_HEIGHT, //8 int
> - MEDIA_ARTWORKURL, //9 string
> - MEDIA_AUDIOTRACK, //10 int
> - MEDIA_SPUTRACK, //11 int
> - MEDIA_TRACKNUMBER, // 12 int
> - MEDIA_LOCATION, //13 string
> + MEDIA_ALBUMARTIST, //7 string
> + MEDIA_WIDTH, //8 int
> + MEDIA_HEIGHT, //9 int
> + MEDIA_ARTWORKURL, //10 string
> + MEDIA_AUDIOTRACK, //11 int
> + MEDIA_SPUTRACK, //12 int
> + MEDIA_TRACKNUMBER, // 13 int
> + MEDIA_LOCATION, //14 string
> MEDIA_TABLE_NAME,
> CHUNK_SIZE,
> chunk_count * CHUNK_SIZE), null);
> @@ -575,12 +579,13 @@ public class MediaDatabase {
> cursor.getString(4), // MEDIA_ARTIST
> cursor.getString(5), // MEDIA_GENRE
> cursor.getString(6), // MEDIA_ALBUM
> - cursor.getInt(7), // MEDIA_WIDTH
> - cursor.getInt(8), // MEDIA_HEIGHT
> - cursor.getString(9), // MEDIA_ARTWORKURL
> - cursor.getInt(10), // MEDIA_AUDIOTRACK
> - cursor.getInt(11), // MEDIA_SPUTRACK
> - cursor.getInt(12)); // MEDIA_TRACKNUMBER
> + cursor.getString(7), // MEDIA_ALBUMARTIST
> + cursor.getInt(8), // MEDIA_WIDTH
> + cursor.getInt(9), // MEDIA_HEIGHT
> + cursor.getString(10), // MEDIA_ARTWORKURL
> + cursor.getInt(11), // MEDIA_AUDIOTRACK
> + cursor.getInt(12), // MEDIA_SPUTRACK
> + cursor.getInt(13)); // MEDIA_TRACKNUMBER
> medias.put(media.getLocation(), media);
>
> count++;
> @@ -645,12 +650,13 @@ public class MediaDatabase {
> MEDIA_ARTIST, //4 string
> MEDIA_GENRE, //5 string
> MEDIA_ALBUM, //6 string
> - MEDIA_WIDTH, //7 int
> - MEDIA_HEIGHT, //8 int
> - MEDIA_ARTWORKURL, //9 string
> - MEDIA_AUDIOTRACK, //10 int
> - MEDIA_SPUTRACK, //11 int
> - MEDIA_TRACKNUMBER, //12 int
> + MEDIA_ALBUMARTIST, //7 string
> + MEDIA_WIDTH, //8 int
> + MEDIA_HEIGHT, //9 int
> + MEDIA_ARTWORKURL, //10 string
> + MEDIA_AUDIOTRACK, //11 int
> + MEDIA_SPUTRACK, //12 int
> + MEDIA_TRACKNUMBER, //13 int
> },
> MEDIA_LOCATION + "=?",
> new String[] { location },
> @@ -669,12 +675,13 @@ public class MediaDatabase {
> cursor.getString(4),
> cursor.getString(5),
> cursor.getString(6),
> - cursor.getInt(7),
> + cursor.getString(7),
> cursor.getInt(8),
> - cursor.getString(9),
> - cursor.getInt(10),
> + cursor.getInt(9),
> + cursor.getString(10),
> cursor.getInt(11),
> - cursor.getInt(12));
> + cursor.getInt(12),
> + cursor.getInt(13));
> }
> cursor.close();
> return media;
> diff --git a/vlc-android/src/org/videolan/vlc/MediaGroup.java b/vlc-android/src/org/videolan/vlc/MediaGroup.java
> index 045e324..df5ef5d 100644
> --- a/vlc-android/src/org/videolan/vlc/MediaGroup.java
> +++ b/vlc-android/src/org/videolan/vlc/MediaGroup.java
> @@ -46,6 +46,7 @@ public class MediaGroup extends Media {
> media.getArtist(),
> media.getGenre(),
> media.getAlbum(),
> + media.getAlbumArtist(),
> media.getWidth(),
> media.getHeight(),
> media.getArtworkURL(),
> diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> index 37163c3..d4df1d5 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> @@ -355,7 +355,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
> public void run() {
> for (int i = 0; i < mediaList.size(); ++i) {
> Media media = mediaList.get(i);
> - mAlbumsAdapter.addSeparator(media.getArtist(), media);
> + mAlbumsAdapter.addSeparator(media.getReferenceArtist(), media);
> mAlbumsAdapter.add(media.getAlbum(), null, media);
> mSongsAdapter.addSeparator(media.getAlbum(), media);
> }
> diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
> index bfd1818..16fdc2c 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
> @@ -133,10 +133,10 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
> switch (type){
> case TYPE_ALBUMS:
> title = media.getAlbum();
> - subTitle = media.getArtist();
> + subTitle = media.getReferenceArtist();
> break;
> case TYPE_ARTISTS:
> - title = media.getArtist();
> + title = media.getReferenceArtist();
> subTitle = null;
> break;
> case TYPE_GENRES:
> diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java b/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
> index 5d10dd0..d0da1ed 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
> @@ -61,7 +61,7 @@ public class MediaComparators {
> public static final Comparator<Media> byArtist = new Comparator<Media>() {
> @Override
> public int compare(Media m1, Media m2) {
> - int res = String.CASE_INSENSITIVE_ORDER.compare(m1.getArtist(), m2.getArtist());
> + int res = String.CASE_INSENSITIVE_ORDER.compare(m1.getReferenceArtist(), m2.getReferenceArtist());
> if (res == 0)
> res = byAlbum.compare(m1, m2);
> return res;
> --
> 1.9.1
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
More information about the Android
mailing list