pull/1295/head
gedoor 4 years ago
parent 7a6155c1e6
commit d5f2000c52
  1. 5
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -135,7 +135,6 @@ class AudioPlayService : BaseService(),
exoPlayer.setMediaSource(mediaSource) exoPlayer.setMediaSource(mediaSource)
exoPlayer.playWhenReady = true exoPlayer.playWhenReady = true
exoPlayer.prepare() exoPlayer.prepare()
exoPlayer.seekTo(position.toLong())
}.onFailure { }.onFailure {
it.printStackTrace() it.printStackTrace()
toastOnUi("$url ${it.localizedMessage}") toastOnUi("$url ${it.localizedMessage}")
@ -177,6 +176,7 @@ class AudioPlayService : BaseService(),
} }
private fun adjustProgress(position: Int) { private fun adjustProgress(position: Int) {
this.position = position
exoPlayer.seekTo(position.toLong()) exoPlayer.seekTo(position.toLong())
} }
@ -201,6 +201,9 @@ class AudioPlayService : BaseService(),
} }
Player.STATE_READY -> { Player.STATE_READY -> {
// 准备好 // 准备好
if (exoPlayer.currentPosition != position.toLong()) {
exoPlayer.seekTo(position.toLong())
}
if (exoPlayer.playWhenReady) { if (exoPlayer.playWhenReady) {
AudioPlay.status = Status.PLAY AudioPlay.status = Status.PLAY
postEvent(EventBus.AUDIO_STATE, Status.PLAY) postEvent(EventBus.AUDIO_STATE, Status.PLAY)

Loading…
Cancel
Save