pull/1391/head
gedoor 3 years ago
parent c380b113c6
commit 4fc3dbb710
  1. 12
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt

@ -95,9 +95,9 @@ class HttpReadAloudService : BaseReadAloudService(),
task = execute {
clearSpeakCache()
removeCacheFile()
ReadAloud.httpTTS?.let { httpTts ->
val httpTts = ReadAloud.httpTTS ?: return@execute
contentList.forEachIndexed { index, item ->
if (isActive) {
ensureActive()
val speakText = item.replace(AppPattern.notReadAloudRegex, "")
val fileName =
md5SpeakFileName(
@ -112,14 +112,14 @@ class HttpReadAloudService : BaseReadAloudService(),
playAudio(fis.fd)
}
} else if (hasSpeakCache(fileName)) { //缓存文件还在,可能还没下载完
return@let
return@forEachIndexed
} else { //没有下载并且没有缓存文件
try {
if (speakText.isEmpty()) {
ensureActive()
createSilentSound(fileName)
return@let
return@forEachIndexed
}
try {
createSpeakCache(fileName)
val analyzeUrl = AnalyzeUrl(
httpTts.url,
@ -197,8 +197,6 @@ class HttpReadAloudService : BaseReadAloudService(),
}
}
}
}
}
@Synchronized
private fun playAudio(fd: FileDescriptor) {

Loading…
Cancel
Save