http朗读下载连续错误5次后自动停止

pull/1560/head^2
gedoor 3 years ago
parent f03ed16cbe
commit f906380c8e
  1. 12
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt

@ -180,22 +180,26 @@ class HttpReadAloudService : BaseReadAloudService(),
is SocketTimeoutException, is ConnectException -> { is SocketTimeoutException, is ConnectException -> {
removeSpeakCache(fileName) removeSpeakCache(fileName)
downloadErrorNo++ downloadErrorNo++
if (playErrorNo > 5) { if (downloadErrorNo > 5) {
downloadErrorNo = 0
createSilentSound(fileName)
val msg = "tts超时或连接错误超过5次\n${it.localizedMessage}" val msg = "tts超时或连接错误超过5次\n${it.localizedMessage}"
AppLog.put(msg, it) AppLog.put(msg, it)
toastOnUi(msg) toastOnUi(msg)
pauseReadAloud(true)
} else { } else {
downloadAudio() downloadAudio()
} }
} }
else -> { else -> {
removeSpeakCache(fileName) removeSpeakCache(fileName)
createSilentSound(fileName) downloadErrorNo++
val msg = "tts下载错误\n${it.localizedMessage}" val msg = "tts下载错误\n${it.localizedMessage}"
AppLog.put(msg, it) AppLog.put(msg, it)
Timber.e(it) Timber.e(it)
if (downloadErrorNo > 5) {
pauseReadAloud(true)
} else {
createSilentSound(fileName)
}
} }
} }
} }

Loading…
Cancel
Save