From a2235ca21d4dd827551c567be3165159134aa34e Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 25 Dec 2019 08:06:57 +0800 Subject: [PATCH] up --- .../java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 +- .../main/java/io/legado/app/service/AudioPlayService.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index bf8aded6d..b5343cf7f 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -117,7 +117,7 @@ class AnalyzeUrl( page?.let { val matcher = pagePattern.matcher(ruleUrl) while (matcher.find()) { - val pages = matcher.group(1).split(",") + val pages = matcher.group(1)!!.split(",") ruleUrl = if (page <= pages.size) { ruleUrl.replace(matcher.group(), pages[page - 1].trim { it <= ' ' }) } else { diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 6855b8b84..ef2638c29 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -26,6 +26,7 @@ import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.help.IntentHelp import io.legado.app.help.MediaHelp +import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.service.help.AudioPlay import io.legado.app.ui.audio.AudioPlayActivity @@ -121,8 +122,10 @@ class AudioPlayService : BaseService(), AudioPlay.status = Status.PLAY postEvent(Bus.AUDIO_STATE, Status.PLAY) mediaPlayer.reset() - val uri = Uri.parse(url) - mediaPlayer.setDataSource(this, uri, AudioPlay.headers()) + val analyzeUrl = + AnalyzeUrl(url, headerMapF = AudioPlay.headers(), useWebView = true) + val uri = Uri.parse(analyzeUrl.url) + mediaPlayer.setDataSource(this, uri, analyzeUrl.headerMap) mediaPlayer.prepareAsync() } catch (e: Exception) { launch {