[Android] AudioProgress: fix audio sometimes being saved
Duncan McNamara
git at videolan.org
Tue May 17 13:30:51 UTC 2022
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Mon May 2 11:37:07 2022 +0200| [207f3a44317069ef59206e8ff52f118f0b28edd6] | committer: Duncan McNamara
AudioProgress: fix audio sometimes being saved
There seems to be a race condition when adding an audio media to history
when it starts, in which it doesnt get the right progress, and hence
getting the progress saved when it shouldn't.
To fix this, a new method was added to media on the medialibrary side,
markAsPlayed to increment playcount and add to history but without
having to call savePosition / Time.
> https://code.videolan.org/videolan/vlc-android/commit/207f3a44317069ef59206e8ff52f118f0b28edd6
---
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 2a13b83cb..4e92d3009 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -1054,9 +1054,15 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
}
}
- val time = player.getCurrentTime()
val canSwitchToVideo = player.canSwitchToVideo()
- if (id != 0L && mw.type != MediaWrapper.TYPE_VIDEO && !canSwitchToVideo && !mw.isPodcast) if (mw.length == 0L) medialibrary.setLastPosition(id, player.lastPosition) else medialibrary.setLastTime(id, time)
+ /*
+ * Because progress isn't saved for non podcast audio (ie. saveMediaMeta), it is
+ * necessary to mark the media as played to add them to history and increment their
+ * playcount.
+ */
+ if (id != 0L && mw.type != MediaWrapper.TYPE_VIDEO && !canSwitchToVideo && !mw.isPodcast) {
+ mw.markAsPlayed()
+ }
}
}
More information about the Android
mailing list