|
|
@ -43,6 +43,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
private val cacheFiles = hashSetOf<String>() |
|
|
|
private val cacheFiles = hashSetOf<String>() |
|
|
|
private var downloadTask: Coroutine<*>? = null |
|
|
|
private var downloadTask: Coroutine<*>? = null |
|
|
|
private var playIndexJob: Job? = null |
|
|
|
private var playIndexJob: Job? = null |
|
|
|
|
|
|
|
private var downloadTaskIsActive = false |
|
|
|
private var downloadErrorNo: Int = 0 |
|
|
|
private var downloadErrorNo: Int = 0 |
|
|
|
private var playErrorNo = 0 |
|
|
|
private var playErrorNo = 0 |
|
|
|
|
|
|
|
|
|
|
@ -103,7 +104,12 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun downloadAudio() { |
|
|
|
private fun downloadAudio() { |
|
|
|
|
|
|
|
launch { |
|
|
|
downloadTask?.cancel() |
|
|
|
downloadTask?.cancel() |
|
|
|
|
|
|
|
while (downloadTaskIsActive) { |
|
|
|
|
|
|
|
//在线tts大部分只能单线程,等待上次访问结束 |
|
|
|
|
|
|
|
delay(100) |
|
|
|
|
|
|
|
} |
|
|
|
downloadTask = execute { |
|
|
|
downloadTask = execute { |
|
|
|
clearSpeakCache() |
|
|
|
clearSpeakCache() |
|
|
|
removeCacheFile() |
|
|
|
removeCacheFile() |
|
|
@ -202,6 +208,11 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}.onStart { |
|
|
|
|
|
|
|
downloadTaskIsActive = true |
|
|
|
|
|
|
|
}.onFinally { |
|
|
|
|
|
|
|
downloadTaskIsActive = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|