From 4b3d363346cfb49d04e36f909fd7610e69829481 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 16 Dec 2019 16:27:04 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/service/AudioPlayService.kt | 4 +++- app/src/main/java/io/legado/app/service/help/AudioPlay.kt | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 3304cbe83..dce04cd2b 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -9,6 +9,7 @@ import android.graphics.BitmapFactory import android.media.AudioFocusRequest import android.media.AudioManager import android.media.MediaPlayer +import android.net.Uri import android.os.Build import android.os.Handler import android.support.v4.media.session.MediaSessionCompat @@ -121,7 +122,8 @@ class AudioPlayService : BaseService(), AudioPlay.status = Status.PLAY postEvent(Bus.AUDIO_STATE, Status.PLAY) mediaPlayer.reset() - mediaPlayer.setDataSource(url) + val uri = Uri.parse(url) + mediaPlayer.setDataSource(this, uri, AudioPlay.headers()) mediaPlayer.prepareAsync() } catch (e: Exception) { launch { diff --git a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt index 98e62606d..67d9d7658 100644 --- a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt +++ b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt @@ -21,6 +21,10 @@ object AudioPlay { var webBook: WebBook? = null val loadingChapters = arrayListOf() + fun headers(): Map? { + return webBook?.bookSource?.getHeaderMap() + } + fun play(context: Context) { val intent = Intent(context, AudioPlayService::class.java) intent.action = Action.play