pull/32/head
kunfei 5 years ago
parent 47b8cb5e20
commit db07f3d728
  1. 14
      app/src/main/java/io/legado/app/service/ReadAloudService.kt
  2. 1
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt

@ -19,6 +19,7 @@ import io.legado.app.help.MediaHelp
import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.service.notification.ReadAloudNotification import io.legado.app.service.notification.ReadAloudNotification
import io.legado.app.ui.widget.page.TextChapter import io.legado.app.ui.widget.page.TextChapter
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt import io.legado.app.utils.getPrefInt
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import io.legado.app.utils.toast import io.legado.app.utils.toast
@ -142,7 +143,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
} }
"pause" -> pauseReadAloud(true) "pause" -> pauseReadAloud(true)
"resume" -> resumeReadAloud() "resume" -> resumeReadAloud()
"upTtsSpeechRate" -> upSpeechRate() "upTtsSpeechRate" -> upSpeechRate(true)
else -> stopSelf() else -> stopSelf()
} }
} }
@ -199,8 +200,15 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
} }
} }
private fun upSpeechRate() { private fun upSpeechRate(reset: Boolean = false) {
textToSpeech?.setSpeechRate((this.getPrefInt("ttsSpeechRate", 5) + 5) / 10f) if (this.getPrefBoolean("ttsFollowSys", true)) {
if (reset) {
clearTTS()
textToSpeech = TextToSpeech(this, this)
}
} else {
textToSpeech?.setSpeechRate((this.getPrefInt("ttsSpeechRate", 5) + 5) / 10f)
}
} }
/** /**

@ -127,6 +127,7 @@ class ReadAloudDialog : DialogFragment() {
private fun upTtsSpeechRate() { private fun upTtsSpeechRate() {
val activity = activity val activity = activity
ReadAloudService.upTtsSpeechRate(requireContext())
if (activity is ReadBookActivity) { if (activity is ReadBookActivity) {
if (activity.readAloudStatus == Status.PLAY) { if (activity.readAloudStatus == Status.PLAY) {
ReadAloudService.pause(requireContext()) ReadAloudService.pause(requireContext())

Loading…
Cancel
Save