diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 3b6fc33c3..981c413f2 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -110,7 +110,6 @@ class AudioPlayService : BaseService(), } private fun play() { - postEvent(Bus.AUDIO_SUB_TITLE, subtitle) upNotification() if (requestFocus()) { try { @@ -230,6 +229,10 @@ class AudioPlayService : BaseService(), if (addLoading(index)) { launch(IO) { App.db.bookChapterDao().getChapter(book.bookUrl, index)?.let { chapter -> + if (index == AudioPlay.durChapterIndex) { + subtitle = chapter.title + postEvent(Bus.AUDIO_SUB_TITLE, subtitle) + } BookHelp.getContent(book, chapter)?.let { contentLoadFinish(chapter, it) removeLoading(chapter.index) @@ -285,6 +288,7 @@ class AudioPlayService : BaseService(), } private fun moveTo(index: Int) { + mediaPlayer.pause() AudioPlay.durChapterIndex = index AudioPlay.durPageIndex = 0 AudioPlay.book?.durChapterIndex = AudioPlay.durChapterIndex @@ -329,7 +333,7 @@ class AudioPlayService : BaseService(), } } - fun saveProgress() { + private fun saveProgress() { launch(IO) { AudioPlay.book?.let { App.db.bookDao().upProgress(it.bookUrl, AudioPlay.durPageIndex)