pull/1822/head
kunfei 3 years ago
parent 9b2d285bae
commit 94334c7de8
  1. 6
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -127,7 +127,7 @@ class AudioPlayService : BaseService(),
private fun play() {
upNotification()
if (requestFocus()) {
kotlin.runCatching {
execute {
AudioPlay.status = Status.STOP
postEvent(EventBus.AUDIO_STATE, Status.STOP)
upPlayProgressJob?.cancel()
@ -141,13 +141,13 @@ class AudioPlayService : BaseService(),
val uri = Uri.parse(analyzeUrl.url)
ExoPlayerHelper.preDownload(uri, analyzeUrl.headerMap)
//休息1秒钟,防止403
Thread.sleep(1000)
delay(1000)
val mediaSource = ExoPlayerHelper
.createMediaSource(uri, analyzeUrl.headerMap)
exoPlayer.setMediaSource(mediaSource)
exoPlayer.playWhenReady = true
exoPlayer.prepare()
}.onFailure {
}.onError {
it.printOnDebug()
toastOnUi("$url ${it.localizedMessage}")
stopSelf()

Loading…
Cancel
Save