[Android] MediaWrapper: Duplicate time field for display
Geoffrey Métais
git at videolan.org
Tue Nov 27 16:19:32 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 27 16:10:35 2018 +0100| [67378666101abfc668f8b5f9ba30f1c8fde39d10] | committer: Geoffrey Métais
MediaWrapper: Duplicate time field for display
Fixes video progress not updated after playback
> https://code.videolan.org/videolan/vlc-android/commit/67378666101abfc668f8b5f9ba30f1c8fde39d10
---
.../videolan/medialibrary/media/MediaWrapper.java | 10 ++++++++++
.../videolan/vlc/gui/video/VideoListAdapter.java | 21 +++++++++++----------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
index 358ec20c1..03fba5d61 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
@@ -110,6 +110,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
private final Uri mUri;
private String mFilename;
private long mTime = 0;
+ private long mDisplayTime = 0;
/* -1 is a valid track (Disabled) */
private int mAudioTrack = -2;
private int mSpuTrack = -2;
@@ -279,6 +280,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
long seen, Media.Slave[] slaves) {
mFilename = null;
mTime = time;
+ mDisplayTime = time;
mAudioTrack = audio;
mSpuTrack = spu;
mLength = length;
@@ -387,6 +389,14 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
mTime = time;
}
+ public long getDisplayTime() {
+ return mDisplayTime;
+ }
+
+ public void setDisplayTime(long time) {
+ mDisplayTime = time;
+ }
+
public int getAudioTrack() {
return mAudioTrack;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index c35b332ee..e19badbf2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -22,14 +22,7 @@ package org.videolan.vlc.gui.video;
import android.annotation.TargetApi;
import android.content.Context;
-import androidx.databinding.BindingAdapter;
-import androidx.databinding.DataBindingUtil;
-import androidx.databinding.ObservableBoolean;
-import androidx.databinding.ViewDataBinding;
import android.os.Build;
-import androidx.annotation.MainThread;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.GridLayoutManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,6 +47,14 @@ import org.videolan.vlc.util.MediaItemDiffCallback;
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.MainThread;
+import androidx.annotation.Nullable;
+import androidx.databinding.BindingAdapter;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ObservableBoolean;
+import androidx.databinding.ViewDataBinding;
+import androidx.recyclerview.widget.GridLayoutManager;
+
public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAdapter.ViewHolder> implements MultiSelectAdapter<MediaWrapper> {
public final static String TAG = "VLC/VideoListAdapter";
@@ -165,7 +166,7 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
/* Time / Duration */
resolution = Tools.getResolution(media);
if (media.getLength() > 0) {
- final long lastTime = media.getTime();
+ final long lastTime = media.getDisplayTime();
if (lastTime > 0) {
max = (int) (media.getLength() / 1000);
progress = (int) (lastTime / 1000);
@@ -289,7 +290,7 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
final MediaWrapper oldItem = oldList.get(oldItemPosition);
final MediaWrapper newItem = newList.get(newItemPosition);
- return oldItem == newItem || (oldItem.getTime() == newItem.getTime()
+ return oldItem == newItem || (oldItem.getDisplayTime() == newItem.getDisplayTime()
&& TextUtils.equals(oldItem.getArtworkMrl(), newItem.getArtworkMrl())
&& oldItem.getSeen() == newItem.getSeen());
}
@@ -299,7 +300,7 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
public Object getChangePayload(int oldItemPosition, int newItemPosition) {
final MediaWrapper oldItem = oldList.get(oldItemPosition);
final MediaWrapper newItem = newList.get(newItemPosition);
- if (oldItem.getTime() != newItem.getTime())
+ if (oldItem.getDisplayTime() != newItem.getDisplayTime())
return Constants.UPDATE_TIME;
if (!TextUtils.equals(oldItem.getArtworkMrl(), newItem.getArtworkMrl()))
return Constants.UPDATE_THUMB;
More information about the Android
mailing list