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

Loading…
Cancel
Save