mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -156,12 +156,8 @@ abstract class BaseReadAloudService : BaseService(),
|
||||
@CallSuper
|
||||
open fun resumeReadAloud() {
|
||||
pause = false
|
||||
if (contentList.isEmpty()) {
|
||||
ReadBook.readAloud()
|
||||
} else {
|
||||
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
||||
postEvent(EventBus.ALOUD_STATE, Status.PLAY)
|
||||
}
|
||||
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
||||
postEvent(EventBus.ALOUD_STATE, Status.PLAY)
|
||||
}
|
||||
|
||||
abstract fun upSpeechRate(reset: Boolean = false)
|
||||
|
||||
@@ -63,18 +63,21 @@ class HttpReadAloudService : BaseReadAloudService(),
|
||||
}
|
||||
|
||||
override fun play() {
|
||||
if (contentList.isEmpty()) return
|
||||
ReadAloud.httpTTS?.let {
|
||||
val fileName =
|
||||
md5SpeakFileName(it.url, AppConfig.ttsSpeechRate.toString(), contentList[nowSpeak])
|
||||
if (nowSpeak == 0) {
|
||||
downloadAudio()
|
||||
} else {
|
||||
val file = getSpeakFileAsMd5(fileName)
|
||||
if (file.exists()) {
|
||||
playAudio(FileInputStream(file).fd)
|
||||
} else {
|
||||
if (contentList.isEmpty()) {
|
||||
ReadBook.readAloud()
|
||||
} else {
|
||||
ReadAloud.httpTTS?.let {
|
||||
val fileName =
|
||||
md5SpeakFileName(it.url, AppConfig.ttsSpeechRate.toString(), contentList[nowSpeak])
|
||||
if (nowSpeak == 0) {
|
||||
downloadAudio()
|
||||
} else {
|
||||
val file = getSpeakFileAsMd5(fileName)
|
||||
if (file.exists()) {
|
||||
playAudio(FileInputStream(file).fd)
|
||||
} else {
|
||||
downloadAudio()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,11 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
||||
|
||||
@Synchronized
|
||||
override fun play() {
|
||||
if (contentList.isNotEmpty() && ttsInitFinish && requestFocus()) {
|
||||
if (!ttsInitFinish) return
|
||||
if (!requestFocus()) return
|
||||
if (contentList.isEmpty()) {
|
||||
ReadBook.readAloud()
|
||||
} else {
|
||||
super.play()
|
||||
execute {
|
||||
MediaHelp.playSilentSound(this@TTSReadAloudService)
|
||||
|
||||
Reference in New Issue
Block a user