Add discNumber to Song and populate it

This commit is contained in:
Adrian Ulrich 2017-11-29 21:10:03 +01:00
parent e788e11e5c
commit 38fb581ee1
3 changed files with 12 additions and 4 deletions

View File

@ -539,9 +539,10 @@ public class FullPlaybackActivity extends SlidingPlaybackActivity
mYear = data.getFirst(MediaMetadataExtractor.YEAR);
mPath = song.path;
String disc = data.getFirst(MediaMetadataExtractor.DISC_NUMBER);
if (disc != null && disc.length() > 0)
mTrack += String.format(" (%s💿)", disc);
mTrack = String.format("%d", song.trackNumber);
if (song.discNumber > 0) {
mTrack += String.format(" (%d💿)", song.discNumber);
}
StringBuilder sb = new StringBuilder(12);
sb.append(decodeMimeType(data.getFirst(MediaMetadataExtractor.MIME_TYPE)));

View File

@ -559,7 +559,7 @@ public class MediaUtils {
songId = -2; // must be less than -1 (-1 defines an empty song object)
// Build minimal fake-database entry for this file
Object[] objData = new Object[] { songId, path, "", "", "", 0, 0, 0, 0 };
Object[] objData = new Object[] { songId, path, "", "", "", 0, 0, 0, 0, 0 };
if (title != null)
objData[2] = title;

View File

@ -62,6 +62,7 @@ public class Song implements Comparable<Song> {
MediaLibrary.ContributorColumns.ARTIST_ID,
MediaLibrary.SongColumns.DURATION,
MediaLibrary.SongColumns.SONG_NUMBER,
MediaLibrary.SongColumns.DISC_NUMBER,
};
public static final String[] EMPTY_PLAYLIST_PROJECTION = {
@ -78,6 +79,7 @@ public class Song implements Comparable<Song> {
MediaLibrary.ContributorColumns.ARTIST_ID,
MediaLibrary.SongColumns.DURATION,
MediaLibrary.SongColumns.SONG_NUMBER,
MediaLibrary.SongColumns.DISC_NUMBER,
};
/**
@ -124,6 +126,10 @@ public class Song implements Comparable<Song> {
* The position of the song in its album.
*/
public int trackNumber;
/**
* The disc number where this song is present.
*/
public int discNumber;
/**
* Song flags. Currently {@link #FLAG_RANDOM} or {@link #FLAG_NO_COVER}.
@ -181,6 +187,7 @@ public class Song implements Comparable<Song> {
artistId = cursor.getLong(6);
duration = cursor.getLong(7);
trackNumber = cursor.getInt(8);
discNumber = cursor.getInt(9);
}
/**