diff --git a/app/src/main/java/io/legado/app/model/AudioPlay.kt b/app/src/main/java/io/legado/app/model/AudioPlay.kt index 991a69a92..84eea5337 100644 --- a/app/src/main/java/io/legado/app/model/AudioPlay.kt +++ b/app/src/main/java/io/legado/app/model/AudioPlay.kt @@ -114,28 +114,30 @@ object AudioPlay { fun prev(context: Context) { Coroutine.async { book?.let { book -> - if (book.durChapterIndex <= 0) { - return@let + if (book.durChapterIndex > 0) { + book.durChapterIndex = book.durChapterIndex - 1 + book.durChapterPos = 0 + durChapter = null + saveRead() + play(context) + } else { + stop(context) } - book.durChapterIndex = book.durChapterIndex - 1 - book.durChapterPos = 0 - durChapter = null - saveRead() - play(context) } } } fun next(context: Context) { book?.let { book -> - if (book.durChapterIndex >= book.totalChapterNum) { - return@let + if (book.durChapterIndex + 1 < book.totalChapterNum) { + book.durChapterIndex = book.durChapterIndex + 1 + book.durChapterPos = 0 + durChapter = null + saveRead() + play(context) + } else { + stop(context) } - book.durChapterIndex = book.durChapterIndex + 1 - book.durChapterPos = 0 - durChapter = null - saveRead() - play(context) } } diff --git a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt index 063a63cc5..d80f1a0bc 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt @@ -269,6 +269,10 @@ class AudioPlayActivity : } observeEventSticky(EventBus.AUDIO_SUB_TITLE) { binding.tvSubTitle.text = it + AudioPlay.book?.let { book -> + binding.ivSkipPrevious.isEnabled = book.durChapterIndex > 0 + binding.ivSkipNext.isEnabled = book.durChapterIndex < book.totalChapterNum - 1 + } } observeEventSticky(EventBus.AUDIO_SIZE) { binding.playerProgress.max = it