From 6aceec6a646ffaad455bc3cb212670b710039cd8 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:22:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20#5437?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/AudioPlay.kt | 7 +++++++ 1 file changed, 7 insertions(+) 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 584da8e03..8df65c4d1 100644 --- a/app/src/main/java/io/legado/app/model/AudioPlay.kt +++ b/app/src/main/java/io/legado/app/model/AudioPlay.kt @@ -49,6 +49,7 @@ object AudioPlay : CoroutineScope by MainScope() { } } } + var playMode = PlayMode.LIST_END_STOP var status = Status.STOP private var activityContext: Context? = null @@ -81,6 +82,7 @@ object AudioPlay : CoroutineScope by MainScope() { chapterSize } if (durChapterIndex != book.durChapterIndex) { + stopPlay() durChapterIndex = book.durChapterIndex durChapterPos = book.durChapterPos durPlayUrl = "" @@ -155,6 +157,8 @@ object AudioPlay : CoroutineScope by MainScope() { }.onError { AppLog.put("获取资源链接出错\n$it", it, true) upLoading(false) + }.onCancel { + removeLoading(index) }.onFinally { removeLoading(index) } @@ -293,12 +297,14 @@ object AudioPlay : CoroutineScope by MainScope() { loadPlayUrl() } } + PlayMode.SINGLE_LOOP -> { durChapterPos = 0 durPlayUrl = "" saveRead() loadPlayUrl() } + PlayMode.RANDOM -> { durChapterIndex = (0 until simulatedChapterSize).random() durChapterPos = 0 @@ -306,6 +312,7 @@ object AudioPlay : CoroutineScope by MainScope() { saveRead() loadPlayUrl() } + PlayMode.LIST_LOOP -> { durChapterIndex = (durChapterIndex + 1) % simulatedChapterSize durChapterPos = 0