|
|
@@ -35,7 +35,7 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|
|
|
|
|
private val mediaPlayer = MediaPlayer()
|
|
|
private val ttsFolderPath: String by lazy {
|
|
|
- externalCacheDir!!.absolutePath + File.separator + "httpTTS" + File.separator
|
|
|
+ cacheDir.absolutePath + File.separator + "httpTTS" + File.separator
|
|
|
}
|
|
|
private val cacheFiles = hashSetOf<String>()
|
|
|
private var task: Coroutine<*>? = null
|
|
|
@@ -261,6 +261,9 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|
|
private fun createSpeakFileAsMd5IfNotExist(name: String): File =
|
|
|
FileUtils.createFileIfNotExist("${ttsFolderPath}$name.mp3")
|
|
|
|
|
|
+ /**
|
|
|
+ * 移除缓存文件
|
|
|
+ */
|
|
|
private fun removeCacheFile() {
|
|
|
val cacheRegex = Regex(""".+\.mp3$""")
|
|
|
val reg = """^${MD5Utils.md5Encode16(textChapter!!.title)}_[a-z0-9]{16}\.mp3$""".toRegex()
|
|
|
@@ -270,7 +273,7 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|
|
FileUtils.deleteFile(it.absolutePath)
|
|
|
}
|
|
|
} else {
|
|
|
- if (Date().time - it.lastModified() > 30000) {
|
|
|
+ if (Date().time - it.lastModified() > 600000) {
|
|
|
FileUtils.deleteFile(it.absolutePath)
|
|
|
}
|
|
|
}
|