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