mirror of
https://github.com/videolan/vlc-android
synced 2024-11-23 09:56:36 +08:00
Add the album artist id to the MediaWrapper
This commit is contained in:
parent
316e3b4c3b
commit
1f0367c991
@ -31,7 +31,7 @@ object DummyMediaWrapperProvider {
|
||||
fun getDummyMediaWrapper(id: Long): MediaWrapper {
|
||||
if (id >= 0) throw IllegalArgumentException("Dummy MediaWrapper id must be < 0")
|
||||
return MLServiceLocator.getAbstractMediaWrapper(id, "dummy://Mrl", -1L, -1F, 18820L, MediaWrapper.TYPE_VIDEO,
|
||||
"", "", -1L, "", "", -1L,
|
||||
"", "", -1L, -1L, "", "", -1L,
|
||||
"", "", 416, 304, "", 0, -2,
|
||||
0, 0, 1509466228L, 0L, true, false, 1970, true, 1683711438317L)
|
||||
}
|
||||
|
@ -436,6 +436,7 @@ class MiniPlayerAppWidgetProvider : AppWidgetProvider() {
|
||||
"Track name",
|
||||
"",
|
||||
-1L,
|
||||
-1L,
|
||||
"Artist name",
|
||||
"",
|
||||
-1L,
|
||||
|
@ -2841,7 +2841,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
GET_ID(GetMethodID,
|
||||
ml_fields.MediaWrapper.initID,
|
||||
ml_fields.MediaWrapper.clazz,
|
||||
"<init>", "(JLjava/lang/String;JFJILjava/lang/String;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;IILjava/lang/String;IIIIJJZZIZJ)V");
|
||||
"<init>", "(JLjava/lang/String;JFJILjava/lang/String;Ljava/lang/String;JJLjava/lang/String;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;IILjava/lang/String;IIIIJJZZIZJ)V");
|
||||
|
||||
GET_CLASS(ml_fields.HistoryItem.clazz,
|
||||
"org/videolan/medialibrary/media/HistoryItem", true);
|
||||
|
@ -26,7 +26,7 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
|
||||
}
|
||||
utils::jni::string artist, genre, album, albumArtist, mrl, title, thumbnail, filename;
|
||||
jint trackNumber = 0, discNumber = 0;
|
||||
int64_t artistId = -1, albumId = -1;
|
||||
int64_t artistId = -1, albumArtistId = -1, albumId = -1;
|
||||
|
||||
const bool isPresent = mediaPtr->isPresent();
|
||||
medialibrary::ArtistPtr artistPtr = mediaPtr->artist();
|
||||
@ -42,8 +42,10 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
|
||||
album = vlcNewStringUTF(env, albumPtr->title().c_str());
|
||||
albumId = albumPtr->id();
|
||||
medialibrary::ArtistPtr albumArtistPtr = albumPtr->albumArtist();
|
||||
if (albumArtistPtr != NULL)
|
||||
if (albumArtistPtr != NULL) {
|
||||
albumArtist = vlcNewStringUTF(env, albumArtistPtr->name().c_str());
|
||||
albumArtistId = albumArtistPtr->id();
|
||||
}
|
||||
}
|
||||
trackNumber = mediaPtr->trackNumber();
|
||||
discNumber = mediaPtr->discNumber();
|
||||
@ -73,7 +75,7 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
|
||||
auto isFavorite = mediaPtr->isFavorite();
|
||||
return { env, env->NewObject(fields->MediaWrapper.clazz, fields->MediaWrapper.initID,
|
||||
(jlong) mediaPtr->id(), mrl.get(), (jlong) mediaPtr->lastTime(), (jfloat) mediaPtr->lastPosition(), (jlong) duration, type,
|
||||
title.get(), filename.get(), (jlong) artistId, artist.get(), genre.get(), (jlong) albumId, album.get(),
|
||||
title.get(), filename.get(), (jlong) artistId, albumArtistId, artist.get(), genre.get(), (jlong) albumId, album.get(),
|
||||
albumArtist.get(), width, height, thumbnail.get(),
|
||||
audioTrack, spuTrack, trackNumber, discNumber, (jlong) files.at(0)->lastModificationDate(),
|
||||
(jlong) mediaPtr->playCount(), hasThumbnail, isFavorite, mediaPtr->releaseDate(), isPresent, (jlong) mediaPtr->insertionDate())
|
||||
|
@ -64,7 +64,7 @@ public class MLServiceLocator {
|
||||
|
||||
// MediaWrapper
|
||||
public static MediaWrapper getAbstractMediaWrapper(long id, String mrl, long time, float position, long length,
|
||||
int type, String title, String filename, long artistId,
|
||||
int type, String title, String filename, long artistId, long albumArtistId,
|
||||
String artist, String genre, long albumId, String album,
|
||||
String albumArtist, int width, int height,
|
||||
String artworkURL, int audio, int spu,
|
||||
@ -73,29 +73,29 @@ public class MLServiceLocator {
|
||||
int releaseDate, boolean isPresent, long insertionDate) {
|
||||
if (sMode == LocatorMode.VLC_ANDROID) {
|
||||
return new MediaWrapperImpl(id, mrl, time, position, length, type, title,
|
||||
filename, artistId, artist, genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
filename, artistId, albumArtistId, artist, genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified, seen, isThumbnailGenerated,
|
||||
isFavorite, releaseDate, isPresent, insertionDate);
|
||||
} else {
|
||||
return new StubMediaWrapper(id, mrl, time, position, length, type, title,
|
||||
filename,artistId, artist, genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
filename,artistId, albumArtistId, artist, genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified, seen, isThumbnailGenerated, isFavorite, releaseDate, isPresent, insertionDate);
|
||||
}
|
||||
}
|
||||
|
||||
public static MediaWrapper getAbstractMediaWrapper(Uri uri, long time, float position, long length, int type,
|
||||
Bitmap picture, String title, long artistId, String artist,
|
||||
Bitmap picture, String title, long artistId, long albumArtistId, String artist,
|
||||
String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL,
|
||||
int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen,
|
||||
long insertionDate) {
|
||||
if (sMode == LocatorMode.VLC_ANDROID) {
|
||||
return new MediaWrapperImpl(uri, time, position, length, type, picture, title, artistId, artist, genre,
|
||||
return new MediaWrapperImpl(uri, time, position, length, type, picture, title, artistId, albumArtistId, artist, genre,
|
||||
albumId, album, albumArtist, width, height, artworkURL, audio, spu, trackNumber,
|
||||
discNumber, lastModified, seen, false, insertionDate);
|
||||
} else {
|
||||
return new StubMediaWrapper(uri, time, position, length, type, picture, title, artistId, artist, genre,
|
||||
return new StubMediaWrapper(uri, time, position, length, type, picture, title, artistId, albumArtistId, artist, genre,
|
||||
albumId, album, albumArtist, width, height, artworkURL, audio, spu, trackNumber,
|
||||
discNumber, lastModified, seen, false, insertionDate);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
|
||||
protected String mDisplayTitle;
|
||||
protected long mArtistId;
|
||||
protected long mAlbumArtistId;
|
||||
protected String mArtist;
|
||||
protected String mGenre;
|
||||
protected String mCopyright;
|
||||
@ -152,6 +153,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
public abstract boolean markAsPlayed();
|
||||
public abstract Album getAlbumWrapper();
|
||||
public abstract Artist getArtistWrapper();
|
||||
public abstract Artist getAlbumArtistWrapper();
|
||||
|
||||
/**
|
||||
* Create a new MediaWrapper
|
||||
@ -159,7 +161,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
* @param mrl Should not be null.
|
||||
*/
|
||||
public MediaWrapper(long id, String mrl, long time, float position, long length, int type, String title,
|
||||
String filename, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
String filename, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isThumbnailGenerated,
|
||||
boolean isFavorite, int releaseDate, boolean isPresent, long insertionDate) {
|
||||
@ -171,7 +173,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
mFilename = filename;
|
||||
mReleaseYear = releaseDate;
|
||||
mIsPresent = isPresent;
|
||||
init(time, position, length, type, null, title, artistId, artist, genre, albumId, album, albumArtist, width, height,
|
||||
init(time, position, length, type, null, title, artistId, albumArtistId, artist, genre, albumId, album, albumArtist, width, height,
|
||||
artworkURL != null ? VLCUtil.UriFromMrl(artworkURL).getPath() : null, audio, spu,
|
||||
trackNumber, discNumber, lastModified, seen, isPresent, null, isFavorite, insertionDate);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@ -318,7 +320,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
}
|
||||
|
||||
private void init(long time, float position, long length, int type,
|
||||
Bitmap picture, String title, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
Bitmap picture, String title, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber, int discNumber, long lastModified,
|
||||
long seen, boolean isPresent, IMedia.Slave[] slaves, boolean isFavorite, long insertionDate) {
|
||||
mFilename = null;
|
||||
@ -336,6 +338,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
|
||||
mTitle = title != null ? title.trim() : null;
|
||||
mArtistId = artistId;
|
||||
mAlbumArtistId = albumArtistId;
|
||||
mArtist = artist != null ? artist.trim() : null;
|
||||
mGenre = genre != null ? genre.trim() : null;
|
||||
mAlbumId = albumId;
|
||||
@ -352,11 +355,11 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
}
|
||||
|
||||
public MediaWrapper(Uri uri, long time, float position, long length, int type,
|
||||
Bitmap picture, String title, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
Bitmap picture, String title, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isFavorite, long insertionDate) {
|
||||
mUri = uri;
|
||||
init(time, position, length, type, picture, title, artistId, artist, genre, albumId, album, albumArtist,
|
||||
init(time, position, length, type, picture, title, artistId, albumArtistId, artist, genre, albumId, album, albumArtist,
|
||||
width, height, artworkURL, audio, spu, trackNumber, discNumber, lastModified, seen, true, null, isFavorite, insertionDate);
|
||||
}
|
||||
|
||||
@ -614,6 +617,10 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
return mArtistId;
|
||||
}
|
||||
|
||||
public long getAlbumArtistId() {
|
||||
return mAlbumArtistId;
|
||||
}
|
||||
|
||||
public Boolean isArtistUnknown() {
|
||||
return mArtist == null;
|
||||
}
|
||||
@ -764,6 +771,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
(Bitmap) in.readParcelable(Bitmap.class.getClassLoader()),
|
||||
in.readString(),
|
||||
in.readLong(),
|
||||
in.readLong(),
|
||||
in.readString(),
|
||||
in.readString(),
|
||||
in.readLong(),
|
||||
@ -795,6 +803,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
dest.writeParcelable(getPicture(), flags);
|
||||
dest.writeString(getTitle());
|
||||
dest.writeLong(getArtistId());
|
||||
dest.writeLong(getAlbumArtistId());
|
||||
dest.writeString(getArtist());
|
||||
dest.writeString(getGenre());
|
||||
dest.writeLong(getAlbumId());
|
||||
|
@ -41,21 +41,21 @@ public class MediaWrapperImpl extends MediaWrapper {
|
||||
public final static String TAG = "VLC/MediaWrapperImpl";
|
||||
|
||||
public MediaWrapperImpl(long id, String mrl, long time, float position, long length, int type, String title,
|
||||
String filename,long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
String filename,long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isThumbnailGenerated,
|
||||
boolean isFavorite, int releaseDate, boolean isPresent, long insertionDate) {
|
||||
super(id, mrl, time, position, length, type, title, filename, artistId, artist,
|
||||
super(id, mrl, time, position, length, type, title, filename, artistId, albumArtistId, artist,
|
||||
genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified,
|
||||
seen, isThumbnailGenerated, isFavorite, releaseDate, isPresent, insertionDate);
|
||||
}
|
||||
|
||||
public MediaWrapperImpl(Uri uri, long time, float position, long length, int type,
|
||||
Bitmap picture, String title, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
Bitmap picture, String title, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isFavorite, long insertionDate) {
|
||||
super(uri, time, position, length, type, picture, title, artistId, artist,
|
||||
super(uri, time, position, length, type, picture, title, artistId, albumArtistId, artist,
|
||||
genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified, seen, isFavorite, insertionDate);
|
||||
}
|
||||
@ -91,6 +91,13 @@ public class MediaWrapperImpl extends MediaWrapper {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artist getAlbumArtistWrapper() {
|
||||
final Medialibrary ml = Medialibrary.getInstance();
|
||||
if (ml.isInitiated()) return ml.getArtist(mAlbumArtistId);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setArtist(String artist) {
|
||||
mArtist = artist;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class StubDataSource {
|
||||
fileName = i + " - " + STUBBED_VIDEO_TITLE + STUBBED_AUDIO_EXTENSION;
|
||||
String mrl = baseMrl + ((folder != null) ? folder + "/" : "") + fileName;
|
||||
media = MLServiceLocator.getAbstractMediaWrapper(getUUID(), mrl, -1L, -1F, 18820L, MediaWrapper.TYPE_VIDEO,
|
||||
fileName, fileName, -1L, "", "", -1L,
|
||||
fileName, fileName, -1L,-1L, "", "", -1L,
|
||||
"", "", 416, 304, "", 0, -2,
|
||||
0, 0, 1509466228L, 0L, true, false, 1970, true, 1683711438317L);
|
||||
addVideo(media);
|
||||
@ -110,7 +110,7 @@ public class StubDataSource {
|
||||
fileName = i + " - " + STUBBED_AUDIO_TITLE + STUBBED_AUDIO_EXTENSION;
|
||||
String mrl = baseMrl + ((folder != null) ? folder + "/" : "") + fileName;
|
||||
media = MLServiceLocator.getAbstractMediaWrapper(getUUID(), mrl, -1L, -1F, 280244L, MediaWrapper.TYPE_AUDIO,
|
||||
i + "-Show Me The Way", fileName, -1L, "Peter Frampton", "Rock", -1L,
|
||||
i + "-Show Me The Way", fileName, -1L,-1L, "Peter Frampton", "Rock", -1L,
|
||||
"Shine On CD2", "Peter Frampton",
|
||||
0, 0, baseMrl + folder + ".jpg",
|
||||
0, -2, 1, 0,
|
||||
@ -396,6 +396,7 @@ public class StubDataSource {
|
||||
jsonObject.getString("title"),
|
||||
jsonObject.getString("filename"),
|
||||
-1L,
|
||||
-1L,
|
||||
jsonObject.getString("artist"),
|
||||
jsonObject.getString("genre"),
|
||||
-1L,
|
||||
@ -560,6 +561,7 @@ public class StubDataSource {
|
||||
media.getTitle(),
|
||||
media.getFileName(),
|
||||
-1L,
|
||||
-1L,
|
||||
media.getArtist(),
|
||||
genre.getTitle(),
|
||||
-1L,
|
||||
@ -590,7 +592,7 @@ public class StubDataSource {
|
||||
|
||||
public MediaWrapper addMediaWrapper(String mrl, String title, int type) {
|
||||
MediaWrapper media = MLServiceLocator.getAbstractMediaWrapper(getUUID(), mrl, -1L, -1F, 280224L, type,
|
||||
title, title, -1L, "Artisto", "Jazz", -1L, "XYZ CD1", "", 0, 0, baseMrl + title, -2,
|
||||
title, title, -1L, -1L, "Artisto", "Jazz", -1L, "XYZ CD1", "", 0, 0, baseMrl + title, -2,
|
||||
1, 1, 0, 1547452796L, 0L, true, false, 0, true, 1683711438317L);
|
||||
if (type == MediaWrapper.TYPE_ALL) type = media.getType();
|
||||
if (type == MediaWrapper.TYPE_VIDEO) addVideo(media);
|
||||
|
@ -14,11 +14,11 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper;
|
||||
|
||||
public class StubMediaWrapper extends MediaWrapper {
|
||||
public StubMediaWrapper(long id, String mrl, long time, float position, long length, int type, String title,
|
||||
String filename, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
String filename, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isThumbnailGenerated,
|
||||
boolean isFavorite, int releaseDate, boolean isPresent, long insertionDate) {
|
||||
super(id, mrl, time, position, length, type, title, filename, artistId, artist,
|
||||
super(id, mrl, time, position, length, type, title, filename, artistId, albumArtistId, artist,
|
||||
genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified,
|
||||
seen, isThumbnailGenerated, isFavorite, releaseDate, isPresent, insertionDate);
|
||||
@ -46,10 +46,10 @@ public class StubMediaWrapper extends MediaWrapper {
|
||||
}
|
||||
|
||||
public StubMediaWrapper(Uri uri, long time, float position, long length, int type,
|
||||
Bitmap picture, String title, long artistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
Bitmap picture, String title, long artistId, long albumArtistId, String artist, String genre, long albumId, String album, String albumArtist,
|
||||
int width, int height, String artworkURL, int audio, int spu, int trackNumber,
|
||||
int discNumber, long lastModified, long seen, boolean isFavorite, long insertionDate) {
|
||||
super(uri, time, position, length, type, picture, title, artistId, artist,
|
||||
super(uri, time, position, length, type, picture, title, artistId, albumArtistId, artist,
|
||||
genre, albumId, album, albumArtist, width, height, artworkURL,
|
||||
audio, spu, trackNumber, discNumber, lastModified, seen, isFavorite, insertionDate);
|
||||
}
|
||||
@ -103,6 +103,11 @@ public class StubMediaWrapper extends MediaWrapper {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artist getAlbumArtistWrapper() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setLongMeta(int metaDataType, long metadataValue) {
|
||||
mMetaLong.setValueAt(metaDataType, metadataValue);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user