From 9c45df05f8663e6a85fe649c8c12b32e111b9d57 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 23 Nov 2020 21:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9F=B3=E9=A2=91=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/AudioPlayService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 340395096..b83c10d7b 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/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,