pull/32/head
kunfei 5 years ago
parent 47b8cb5e20
commit db07f3d728
  1. 12
      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.service.notification.ReadAloudNotification
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.postEvent
import io.legado.app.utils.toast
@ -142,7 +143,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
}
"pause" -> pauseReadAloud(true)
"resume" -> resumeReadAloud()
"upTtsSpeechRate" -> upSpeechRate()
"upTtsSpeechRate" -> upSpeechRate(true)
else -> stopSelf()
}
}
@ -199,9 +200,16 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
}
}
private fun upSpeechRate() {
private fun upSpeechRate(reset: Boolean = false) {
if (this.getPrefBoolean("ttsFollowSys", true)) {
if (reset) {
clearTTS()
textToSpeech = TextToSpeech(this, this)
}
} else {
textToSpeech?.setSpeechRate((this.getPrefInt("ttsSpeechRate", 5) + 5) / 10f)
}
}
/**
* 初始化MediaSession

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

Loading…
Cancel
Save