[Android] Save media time every 20sec to prevent progress loss
Nicolas Pomepuy
git at videolan.org
Thu Mar 17 16:26:05 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Mar 10 14:49:57 2022 +0100| [bc360565a93561dbaa60b00ed12f3784a0a041cc] | committer: Duncan McNamara
Save media time every 20sec to prevent progress loss
Fixes #2410
> https://code.videolan.org/videolan/vlc-android/commit/bc360565a93561dbaa60b00ed12f3784a0a041cc
---
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 7 +++++++
1 file changed, 7 insertions(+)
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 c2f5c24ac..0b59daa2c 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -931,6 +931,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
private val mediaplayerEventListener = object : MediaPlayerEventListener {
+ private var lastTimeMetaSaved = 0L
+
override suspend fun onEvent(event: MediaPlayer.Event) {
when (event.type) {
MediaPlayer.Event.Playing -> {
@@ -996,6 +998,11 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (it.stop != -1L && player.getCurrentTime() > it.stop) service.setTime(it.start)
}
if (player.getCurrentTime() % 10 == 0L) savePosition()
+ val now = System.currentTimeMillis()
+ if (now - lastTimeMetaSaved > 20000){
+ lastTimeMetaSaved = now
+ saveMediaMeta()
+ }
}
MediaPlayer.Event.SeekableChanged -> if (event.seekable && settings.getBoolean(if(player.isVideoPlaying()) KEY_PLAYBACK_SPEED_PERSIST_VIDEO else KEY_PLAYBACK_SPEED_PERSIST, false)) {
player.setRate(settings.getFloat(if(player.isVideoPlaying()) KEY_PLAYBACK_RATE_VIDEO else KEY_PLAYBACK_RATE, 1.0f), false)
More information about the Android
mailing list