pull/61/head^2
kunfei 5 years ago
parent 2ee9a99883
commit 4b3d363346
  1. 4
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  2. 4
      app/src/main/java/io/legado/app/service/help/AudioPlay.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 {

@ -21,6 +21,10 @@ object AudioPlay {
var webBook: WebBook? = null
val loadingChapters = arrayListOf<Int>()
fun headers(): Map<String, String>? {
return webBook?.bookSource?.getHeaderMap()
}
fun play(context: Context) {
val intent = Intent(context, AudioPlayService::class.java)
intent.action = Action.play

Loading…
Cancel
Save