From 86c4e247d23348b67144444d0806854c8a219635 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 24 Oct 2019 09:17:38 +0800 Subject: [PATCH] up --- .../java/io/legado/app/service/HttpReadAloudService.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 221ba3a45..90754a09c 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -23,7 +23,8 @@ class HttpReadAloudService : BaseReadAloudService(), MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener { - private var mediaPlayer = MediaPlayer() + private val mediaPlayer = MediaPlayer() + private val ttsFolder = cacheDir.absolutePath + File.separator + "bdTts" private var playingIndex = -1 override fun onCreate() { @@ -69,7 +70,7 @@ class HttpReadAloudService : BaseReadAloudService(), private fun downloadAudio() { launch(IO) { - FileHelp.deleteFile(cacheDir.absolutePath + File.separator + "bdTts") + FileHelp.deleteFile(ttsFolder) for (index in 0 until contentList.size) { val bytes = HttpHelper.getByteRetrofit("http://tts.baidu.com") .create(IHttpPostApi::class.java) @@ -102,7 +103,7 @@ class HttpReadAloudService : BaseReadAloudService(), } private fun getSpeakFile(index: Int = nowSpeak): File { - return FileHelp.getFile("${cacheDir.absolutePath}${File.separator}bdTts${File.separator}${index}.mp3") + return FileHelp.getFile("${ttsFolder}${File.separator}${index}.mp3") } override fun pauseReadAloud(pause: Boolean) {