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