[Android] Add 'seen' meta for MediaWrapper
Geoffrey Métais
git at videolan.org
Fri Jul 7 17:05:49 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul 6 09:44:17 2017 +0200| [2dfb5e5186b03f187d0ffd2236c9300f5cef0623] | committer: Alexandre Perraud
Add 'seen' meta for MediaWrapper
> https://code.videolan.org/videolan/vlc-android/commit/2dfb5e5186b03f187d0ffd2236c9300f5cef0623
---
medialibrary/jni/medialibrary.cpp | 2 +-
medialibrary/jni/utils.cpp | 3 +-
.../videolan/medialibrary/media/MediaWrapper.java | 33 ++++++++++++++++------
.../src/org/videolan/vlc/media/MediaDatabase.java | 6 ++--
.../src/org/videolan/vlc/media/MediaGroup.java | 3 +-
5 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 9cf788a4c..499142214 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -937,7 +937,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetMethodID,
ml_fields.MediaWrapper.initID,
ml_fields.MediaWrapper.clazz,
- "<init>", "(JLjava/lang/String;JJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;IIIIJ)V");
+ "<init>", "(JLjava/lang/String;JJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;IIIIJJ)V");
///
GET_CLASS(ml_fields.HistoryItem.clazz,
diff --git a/medialibrary/jni/utils.cpp b/medialibrary/jni/utils.cpp
index c4e54a9a7..f10fb727c 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -60,12 +60,13 @@ mediaToMediaWrapper(JNIEnv* env, fields *fields, medialibrary::MediaPtr const& m
unsigned int height = hasVideoTracks ? videoTracks.at(0)->height() : 0;
int64_t duration = mediaPtr->duration();
int64_t progress = duration * ( mediaPtr->metadata( medialibrary::IMedia::MetadataType::Progress ).integer() / 100.0 );
+ int64_t seen = mediaPtr->metadata( medialibrary::IMedia::MetadataType::Seen ).integer();
jobject item = env->NewObject(fields->MediaWrapper.clazz, fields->MediaWrapper.initID,
(jlong) mediaPtr->id(), mrl,(jlong) progress, (jlong) duration, type,
title, artist, genre, album,
albumArtist, width, height, thumbnail,
- (jint) -2, (jint) -2, (jint) 0, (jint) 0, (jlong) files.at(0)->lastModificationDate());
+ (jint) -2, (jint) -2, (jint) 0, (jint) 0, (jlong) files.at(0)->lastModificationDate(), seen);
if (artist != NULL)
env->DeleteLocalRef(artist);
if (genre != NULL)
diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
index f3196bb32..8e80ea23a 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
@@ -118,13 +118,16 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
private long mLastModified = 0l;
private Media.Slave mSlaves[] = null;
+ private long mSeen = 0l;
+
/**
* Create a new MediaWrapper
* @param mrl Should not be null.
*/
- public MediaWrapper(long id, String mrl, long time, long length, int type,
- String title, String artist, String genre, String album, String albumArtist, int width,
- int height, String artworkURL, int audio, int spu, int trackNumber, int discNumber, long lastModified) {
+ public MediaWrapper(long id, String mrl, long time, long length, int type, String title,
+ String artist, String genre, String album, String albumArtist, int width,
+ int height, String artworkURL, int audio, int spu, int trackNumber,
+ int discNumber, long lastModified, long seen) {
super();
if (TextUtils.isEmpty(mrl))
throw new IllegalArgumentException("uri was empty");
@@ -133,7 +136,9 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
mrl = "file://"+mrl;
mUri = Uri.parse(mrl);
mId = id;
- init(time, length, type, null, title, artist, genre, album, albumArtist, width, height, artworkURL != null ? VLCUtil.UriFromMrl(artworkURL).getPath() : null, audio, spu, trackNumber, discNumber, lastModified, null);
+ init(time, length, type, null, title, artist, genre, album, albumArtist, width, height,
+ artworkURL != null ? VLCUtil.UriFromMrl(artworkURL).getPath() : null, audio, spu,
+ trackNumber, discNumber, lastModified, seen, null);
sb.setLength(0);
if (type == TYPE_AUDIO) {
boolean hasArtistMeta = !TextUtils.isEmpty(artist);
@@ -265,7 +270,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
private void init(long time, long length, int type,
Bitmap picture, String title, String artist, String genre, String album, String albumArtist,
int width, int height, String artworkURL, int audio, int spu, int trackNumber, int discNumber, long lastModified,
- Media.Slave[] slaves) {
+ long seen, Media.Slave[] slaves) {
mFilename = null;
mTime = time;
mAudioTrack = audio;
@@ -285,15 +290,16 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
mTrackNumber = trackNumber;
mDiscNumber = discNumber;
mLastModified = lastModified;
+ mSeen = seen;
mSlaves = slaves;
}
public MediaWrapper(Uri uri, long time, long length, int type,
Bitmap picture, String title, String artist, String genre, String album, String albumArtist,
- int width, int height, String artworkURL, int audio, int spu, int trackNumber, int discNumber, long lastModified) {
+ int width, int height, String artworkURL, int audio, int spu, int trackNumber, int discNumber, long lastModified, long seen) {
mUri = uri;
init(time, length, type, picture, title, artist, genre, album, albumArtist,
- width, height, artworkURL, audio, spu, trackNumber, discNumber, lastModified, null);
+ width, height, artworkURL, audio, spu, trackNumber, discNumber, lastModified, seen, null);
}
@Override
@@ -557,6 +563,14 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
this.mLastModified = mLastModified;
}
+ public long getSeen() {
+ return mSeen;
+ }
+
+ public void setSeen(long seen) {
+ mSeen = seen;
+ }
+
public void addFlags(int flags) {
mFlags |= flags;
}
@@ -614,7 +628,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
in.readLong(),
in.readInt(),
(Bitmap) in.readParcelable(Bitmap.class.getClassLoader()),
- mTitle,
+ in.readString(),
in.readString(),
in.readString(),
in.readString(),
@@ -627,6 +641,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
in.readInt(),
in.readInt(),
in.readLong(),
+ in.readLong(),
in.createTypedArray(PSlave.CREATOR));
}
@@ -638,6 +653,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
dest.writeLong(getLength());
dest.writeInt(getType());
dest.writeParcelable(getPicture(), flags);
+ dest.writeString(getTitle());
dest.writeString(getArtist());
dest.writeString(getGenre());
dest.writeString(getAlbum());
@@ -650,6 +666,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
dest.writeInt(getTrackNumber());
dest.writeInt(getDiscNumber());
dest.writeLong(getLastModified());
+ dest.writeLong(getSeen());
if (mSlaves != null) {
PSlave pslaves[] = new PSlave[mSlaves.length];
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
index 016e63327..d711bf6b5 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
@@ -829,7 +829,8 @@ public class MediaDatabase {
cursor.getInt(13), // MEDIA_SPUTRACK
cursor.getInt(14), // MEDIA_TRACKNUMBER
cursor.getInt(15), // MEDIA_DISCNUMBER
- cursor.getLong(16)); // MEDIA_LAST_MODIFIED
+ cursor.getLong(16), // MEDIA_LAST_MODIFIED
+ 0L); // MEDIA_SEEN
medias.put(media.getUri().toString(), media);
count++;
@@ -935,7 +936,8 @@ public class MediaDatabase {
cursor.getInt(12),
cursor.getInt(13),
cursor.getInt(14),
- cursor.getLong(15));
+ cursor.getLong(15),
+ 0L);
}
cursor.close();
}
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaGroup.java b/vlc-android/src/org/videolan/vlc/media/MediaGroup.java
index 147199b97..28644a86a 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaGroup.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaGroup.java
@@ -54,7 +54,8 @@ public class MediaGroup extends MediaWrapper {
media.getSpuTrack(),
media.getTrackNumber(),
media.getDiscNumber(),
- 0l);
+ media.getLastModified(),
+ media.getSeen());
mMedias = new ArrayList<MediaWrapper>();
mMedias.add(media);
}
More information about the Android
mailing list