pull/32/head
kunfei 5 years ago
parent dce4342827
commit b25124d7cc
  1. 28
      app/src/main/java/io/legado/app/service/ReadAloudService.kt
  2. 2
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt

@ -75,6 +75,22 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
}
}
fun prevParagraph(context: Context) {
if (isRun) {
val intent = Intent(context, ReadAloudService::class.java)
intent.action = "prevParagraph"
context.startService(intent)
}
}
fun nextParagraph(context: Context) {
if (isRun) {
val intent = Intent(context, ReadAloudService::class.java)
intent.action = "nextParagraph"
context.startService(intent)
}
}
fun upTtsSpeechRate(context: Context) {
if (isRun) {
val intent = Intent(context, ReadAloudService::class.java)
@ -144,6 +160,8 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
"pause" -> pauseReadAloud(true)
"resume" -> resumeReadAloud()
"upTtsSpeechRate" -> upSpeechRate(true)
"prevParagraph" -> prevP()
"nextParagraph" -> nextP()
else -> stopSelf()
}
}
@ -211,6 +229,16 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage
}
}
private fun prevP() {
nowSpeak++
playTTS()
}
private fun nextP() {
nowSpeak--
playTTS()
}
/**
* 初始化MediaSession
*/

@ -115,6 +115,8 @@ class ReadAloudDialog : DialogFragment() {
}
iv_stop.onClick { ReadAloudService.stop(requireContext()) }
iv_play_pause.onClick { postEvent(Bus.READ_ALOUD_BUTTON, true) }
iv_play_prev.onClick { ReadAloudService.prevParagraph(requireContext()) }
iv_play_next.onClick { ReadAloudService.nextParagraph(requireContext()) }
}
private fun upPlayState(state: Int) {

Loading…
Cancel
Save