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 3155c2764..0a2c23e4d 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -64,6 +64,7 @@ class AudioPlayService : BaseService(), mediaPlayer.setOnCompletionListener(this) initMediaSession() initBroadcastReceiver() + upNotification() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) launch(IO) { while (isActive) { @@ -95,6 +96,7 @@ class AudioPlayService : BaseService(), override fun onDestroy() { super.onDestroy() isRun = false + mediaPlayer.release() mediaSessionCompat?.release() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED) postEvent(Bus.AUDIO_STATE, Status.STOP) @@ -114,6 +116,7 @@ class AudioPlayService : BaseService(), mediaPlayer.pause() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) postEvent(Bus.AUDIO_STATE, Status.PAUSE) + upNotification() } private fun resume() { @@ -121,6 +124,7 @@ class AudioPlayService : BaseService(), mediaPlayer.start() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) postEvent(Bus.AUDIO_STATE, Status.PLAY) + upNotification() } override fun onPrepared(mp: MediaPlayer?) {