pull/63/head
kunfei 5 years ago
parent d9e2f979ae
commit a2235ca21d
  1. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  2. 7
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -117,7 +117,7 @@ class AnalyzeUrl(
page?.let { page?.let {
val matcher = pagePattern.matcher(ruleUrl) val matcher = pagePattern.matcher(ruleUrl)
while (matcher.find()) { while (matcher.find()) {
val pages = matcher.group(1).split(",") val pages = matcher.group(1)!!.split(",")
ruleUrl = if (page <= pages.size) { ruleUrl = if (page <= pages.size) {
ruleUrl.replace(matcher.group(), pages[page - 1].trim { it <= ' ' }) ruleUrl.replace(matcher.group(), pages[page - 1].trim { it <= ' ' })
} else { } else {

@ -26,6 +26,7 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.IntentHelp import io.legado.app.help.IntentHelp
import io.legado.app.help.MediaHelp import io.legado.app.help.MediaHelp
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.service.help.AudioPlay import io.legado.app.service.help.AudioPlay
import io.legado.app.ui.audio.AudioPlayActivity import io.legado.app.ui.audio.AudioPlayActivity
@ -121,8 +122,10 @@ class AudioPlayService : BaseService(),
AudioPlay.status = Status.PLAY AudioPlay.status = Status.PLAY
postEvent(Bus.AUDIO_STATE, Status.PLAY) postEvent(Bus.AUDIO_STATE, Status.PLAY)
mediaPlayer.reset() mediaPlayer.reset()
val uri = Uri.parse(url) val analyzeUrl =
mediaPlayer.setDataSource(this, uri, AudioPlay.headers()) AnalyzeUrl(url, headerMapF = AudioPlay.headers(), useWebView = true)
val uri = Uri.parse(analyzeUrl.url)
mediaPlayer.setDataSource(this, uri, analyzeUrl.headerMap)
mediaPlayer.prepareAsync() mediaPlayer.prepareAsync()
} catch (e: Exception) { } catch (e: Exception) {
launch { launch {

Loading…
Cancel
Save