diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 4c9d247ce..3611280ce 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -161,17 +161,22 @@ class AudioPlayService : BaseService(), } private fun resume() { - pause = false - if (!mediaPlayer.isPlaying) { - mediaPlayer.start() - mediaPlayer.seekTo(position) + try { + pause = false + if (!mediaPlayer.isPlaying) { + mediaPlayer.start() + mediaPlayer.seekTo(position) + } + handler.removeCallbacks(mpRunnable) + handler.postDelayed(mpRunnable, 1000) + upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + AudioPlay.status = Status.PLAY + postEvent(EventBus.AUDIO_STATE, Status.PLAY) + upNotification() + } catch (e: Exception) { + e.printStackTrace() + stopSelf() } - handler.removeCallbacks(mpRunnable) - handler.postDelayed(mpRunnable, 1000) - upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) - AudioPlay.status = Status.PLAY - postEvent(EventBus.AUDIO_STATE, Status.PLAY) - upNotification() } private fun adjustProgress(position: Int) {