[Android] Fine tune the chapter navigation
Nicolas Pomepuy
git at videolan.org
Thu Sep 5 08:48:58 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Aug 8 08:55:57 2024 +0200| [a6bb8875322a3398b594e30f9d3f6de987dfd596] | committer: Nicolas Pomepuy
Fine tune the chapter navigation
> https://code.videolan.org/videolan/vlc-android/commit/a6bb8875322a3398b594e30f9d3f6de987dfd596
---
.../src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index d65bf2e4de..a07ca57b01 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -31,6 +31,7 @@ import android.support.v4.media.session.PlaybackStateCompat
import android.text.Editable
import android.text.TextWatcher
import android.text.format.DateFormat
+import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
@@ -930,9 +931,17 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
}
currentChapters?.second?.let { chapters ->
- playlistModel.service!!.chapterIdx =
- playlistModel.service!!.chapterIdx.plus(if (next) 1 else -1)
- .coerceIn(0, chapters.size - 1)
+ playlistModel.service?.let { service ->
+ val chapterIdx = playlistModel.service!!.chapterIdx
+ if (!next) {
+ val chapter = chapters[service.chapterIdx]
+ if (chapter.timeOffset + 5000 > service.getTime())
+ playlistModel.service!!.chapterIdx = chapterIdx.plus(-1).coerceAtLeast(0)
+ else
+ playlistModel.service!!.chapterIdx = chapterIdx
+ } else if (chapterIdx != chapters.size - 1)
+ playlistModel.service!!.chapterIdx = chapterIdx.plus(1).coerceAtMost(chapters.size - 1)
+ }
}
}
}
More information about the Android
mailing list