pull/32/head
kunfei 5 years ago
parent f4805c6c8d
commit 1dfda8ffde
  1. 2
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 12
      app/src/main/java/io/legado/app/service/ReadAloudService.kt

@ -4,4 +4,6 @@ object Bus {
const val RECREATE = "RECREATE"
const val UP_BOOK = "sourceDebugLog"
const val ALOUD_STATE = "aloud_state"
const val TTS_START = "ttsStart"
const val TTS_RANGE_START = "readAloudNumber"
}

@ -268,11 +268,21 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
private inner class TTSUtteranceListener : UtteranceProgressListener() {
override fun onStart(s: String) {
postEvent(Bus.TTS_START, readAloudNumber + 1)
postEvent(Bus.TTS_RANGE_START, readAloudNumber + 1)
}
override fun onDone(s: String) {
readAloudNumber += contentList[nowSpeak].length + 1
nowSpeak += 1
if (nowSpeak >= contentList.size) {
postEvent(Bus.ALOUD_STATE, Status.NEXT)
}
}
override fun onRangeStart(utteranceId: String?, start: Int, end: Int, frame: Int) {
super.onRangeStart(utteranceId, start, end, frame)
postEvent(Bus.TTS_RANGE_START, readAloudNumber + start)
}
override fun onError(s: String) {

Loading…
Cancel
Save