diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 30e2b86a0..a0518651b 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -215,7 +215,6 @@ object ReadBook : CoroutineScope by MainScope() { */ fun readAloud(play: Boolean = true) { book?.let { - ReadAloud.upReadAloudClass() ReadAloud.play(appCtx, play) } } diff --git a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt index 0c66e9181..5e1fabc5f 100644 --- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt @@ -86,6 +86,7 @@ class MediaButtonReceiver : BroadcastReceiver() { LifecycleHelp.isExistActivity(AudioPlayActivity::class.java) -> postEvent(EventBus.MEDIA_BUTTON, true) else -> if (AppConfig.mediaButtonOnExit || LifecycleHelp.activitySize() > 0 || !isMediaKey) { + ReadAloud.upReadAloudClass() if (ReadBook.book != null) { ReadBook.readAloud() } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index ab35358a1..da828bc2e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -863,7 +863,10 @@ class ReadBookActivity : BaseReadBookActivity(), override fun onClickReadAloud() { autoPageStop() when { - !BaseReadAloudService.isRun -> ReadBook.readAloud() + !BaseReadAloudService.isRun -> { + ReadAloud.upReadAloudClass() + ReadBook.readAloud() + } BaseReadAloudService.pause -> ReadAloud.resume(this) else -> ReadAloud.pause(this) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt index 05dbf478e..e164d515a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt @@ -105,6 +105,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di tvFooterLeft.setOnClickListener { ReadBook.book?.setTtsEngine(ttsEngine) callBack.upSpeakEngineSummary() + ReadAloud.upReadAloudClass() dismissAllowingStateLoss() } tvOk.setText(R.string.general) @@ -112,6 +113,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di tvOk.setOnClickListener { ReadBook.book?.setTtsEngine(null) AppConfig.ttsEngine = ttsEngine + ReadAloud.upReadAloudClass() dismissAllowingStateLoss() } tvCancel.visible()