修复音频的一个报错

pull/508/head
gedoor 4 years ago
parent a013ae82fa
commit 9c45df05f8
  1. 6
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -131,6 +131,7 @@ class AudioPlayService : BaseService(),
mediaPlayer.setDataSource(this, uri, analyzeUrl.headerMap)
mediaPlayer.prepareAsync()
} catch (e: Exception) {
e.printStackTrace()
launch {
toast("$url ${e.localizedMessage}")
stopSelf()
@ -147,7 +148,7 @@ class AudioPlayService : BaseService(),
AudioPlayService.pause = pause
handler.removeCallbacks(mpRunnable)
position = mediaPlayer.currentPosition
mediaPlayer.pause()
if (mediaPlayer.isPlaying) mediaPlayer.pause()
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED)
AudioPlay.status = Status.PAUSE
postEvent(EventBus.AUDIO_STATE, Status.PAUSE)
@ -417,8 +418,7 @@ class AudioPlayService : BaseService(),
})
mediaSessionCompat?.setMediaButtonReceiver(
PendingIntent.getBroadcast(
this,
0,
this, 0,
Intent(
Intent.ACTION_MEDIA_BUTTON,
null,

Loading…
Cancel
Save