[Android] Patch: Read tracknumber metadata to sort album's tracklist
Edward Wang
edward.c.wang at compdigitec.com
Thu Dec 4 21:10:14 CET 2014
Hi,
On 2014-12-04 11:18, Enno G. <mrmaffen at googlemail.com> wrote:
> + try {
> + mTrackNumber = Integer.parseInt(track.TrackNumber);
> + } catch (NumberFormatException ignored) {
> + }
Perhaps set some default number for the field to prevent an error?
> Log.d(TAG, "Title " + mTitle);
> Log.d(TAG, "Artist " + mArtist);
> Log.d(TAG, "Genre " + mGenre);
> @@ -206,7 +210,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,
> - int width, int height, String artworkURL, int audio, int spu) {
> + int width, int height, String artworkURL, int audio, int spu, int trackNumber) {
> mLocation = location;
> mFilename = null;
> mTime = time;
> @@ -223,6 +227,7 @@ public class Media implements Comparable<Media> {
> mGenre = getValueWrapper(genre, UnknownStringType.Genre);
> mAlbum = getValueWrapper(album, UnknownStringType.Album);
> mArtworkURL = artworkURL;
> + mTrackNumber = trackNumber;
> }
>
> private enum UnknownStringType { Artist , Genre, Album };
> @@ -433,7 +438,7 @@ public class Media implements Comparable<Media> {
> return (mAlbum.equals(getValueWrapper(null, UnknownStringType.Album)));
> }
>
> - public String getTrackNumber() {
> + public int getTrackNumber() {
> return mTrackNumber;
> }
>
> diff --git a/libvlc/src/org/videolan/libvlc/TrackInfo.java b/libvlc/src/org/videolan/libvlc/TrackInfo.java
> index b651540..49a4f06 100644
> --- a/libvlc/src/org/videolan/libvlc/TrackInfo.java
> +++ b/libvlc/src/org/videolan/libvlc/TrackInfo.java
> @@ -51,4 +51,5 @@ public class TrackInfo {
> public String Genre;
> public String ArtworkURL;
> public String NowPlaying;
> + public String TrackNumber;
> }
> diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
> index b0ca809..a1d5967 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 = 8;
> + private final int DB_VERSION = 9;
> private final int CHUNK_SIZE = 50;
>
The rest looks good.
Regards,
Edward Wang
More information about the Android
mailing list