From c88309b9d177f387f883c853acfd7aa36c6358c2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 Nov 2019 10:15:23 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/service/AudioPlayService.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 a75bf9ab9..974bf1e6a 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -19,6 +19,7 @@ import io.legado.app.base.BaseService import io.legado.app.constant.Action import io.legado.app.constant.AppConst import io.legado.app.constant.Bus +import io.legado.app.constant.Status import io.legado.app.help.IntentHelp import io.legado.app.help.MediaHelp import io.legado.app.receiver.MediaButtonReceiver @@ -96,10 +97,12 @@ class AudioPlayService : BaseService(), isRun = false mediaSessionCompat?.release() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED) + postEvent(Bus.AUDIO_STATE, Status.STOP) } private fun play(url: String) { if (requestFocus()) { + postEvent(Bus.AUDIO_STATE, Status.PLAY) mediaPlayer.reset() mediaPlayer.setDataSource(url) mediaPlayer.prepareAsync() @@ -110,12 +113,14 @@ class AudioPlayService : BaseService(), this.pause = pause mediaPlayer.pause() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) + postEvent(Bus.AUDIO_STATE, Status.PAUSE) } private fun resume() { pause = false mediaPlayer.start() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + postEvent(Bus.AUDIO_STATE, Status.PLAY) } override fun onPrepared(mp: MediaPlayer?) {