|
|
@ -120,6 +120,9 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val handler = Handler() |
|
|
|
private val handler = Handler() |
|
|
|
|
|
|
|
private val ttsParams by lazy { |
|
|
|
|
|
|
|
hashMapOf(Pair(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "content")) |
|
|
|
|
|
|
|
} |
|
|
|
private var ttsIsSuccess: Boolean = false |
|
|
|
private var ttsIsSuccess: Boolean = false |
|
|
|
private lateinit var audioManager: AudioManager |
|
|
|
private lateinit var audioManager: AudioManager |
|
|
|
private lateinit var mFocusRequest: AudioFocusRequest |
|
|
|
private lateinit var mFocusRequest: AudioFocusRequest |
|
|
@ -234,14 +237,22 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, |
|
|
|
ReadAloudNotification.upNotification(this) |
|
|
|
ReadAloudNotification.upNotification(this) |
|
|
|
for (i in nowSpeak until contentList.size) { |
|
|
|
for (i in nowSpeak until contentList.size) { |
|
|
|
if (i == 0) { |
|
|
|
if (i == 0) { |
|
|
|
textToSpeech?.speak(contentList[i], TextToSpeech.QUEUE_FLUSH, null, "content$i") |
|
|
|
speak(contentList[i], TextToSpeech.QUEUE_FLUSH) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
textToSpeech?.speak(contentList[i], TextToSpeech.QUEUE_ADD, null, "content$i") |
|
|
|
speak(contentList[i], TextToSpeech.QUEUE_ADD) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun speak(content: String, queueMode: Int) { |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
|
|
|
|
|
|
|
textToSpeech?.speak(content, queueMode, null, "content") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
textToSpeech?.speak(content, queueMode, ttsParams) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun setTimer(minute: Int) { |
|
|
|
private fun setTimer(minute: Int) { |
|
|
|
timeMinute = minute |
|
|
|
timeMinute = minute |
|
|
|
if (minute > 0) { |
|
|
|
if (minute > 0) { |
|
|
|