feat: 优化

pull/209/head
kunfei 5 years ago
parent d9c7f73764
commit a3ddf6a435
  1. 14
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -20,11 +20,13 @@ import java.util.*
class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener {
companion object {
var textToSpeech: TextToSpeech? = null
private var textToSpeech: TextToSpeech? = null
fun clearTTS() {
textToSpeech?.stop()
textToSpeech?.shutdown()
textToSpeech?.let {
it.stop()
it.shutdown()
}
textToSpeech = null
}
}
@ -45,9 +47,11 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
@Synchronized
override fun onInit(status: Int) {
if (status == TextToSpeech.SUCCESS) {
textToSpeech?.language = Locale.CHINA
textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener())
textToSpeech?.let {
it.language = Locale.CHINA
it.setOnUtteranceProgressListener(TTSUtteranceListener())
ttsInitFinish = true
}
play()
} else {
launch {

Loading…
Cancel
Save