From c0779256e298d02f4859c3625ff7a28e6bb460fb Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 11 Sep 2019 17:44:46 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/service/BaseReadAloudService.kt | 6 +++++- .../main/java/io/legado/app/service/HttpReadAloudService.kt | 1 + .../main/java/io/legado/app/service/TTSReadAloudService.kt | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index f830109e2..24f82da67 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -189,7 +189,11 @@ abstract class BaseReadAloudService : BaseService(), } ?: stopSelf() } - abstract fun play() + open fun play() { + upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + postEvent(Bus.ALOUD_STATE, Status.PLAY) + upNotification() + } @CallSuper open fun pauseReadAloud(pause: Boolean) { diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 43bca75b2..1de2f030a 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -74,6 +74,7 @@ class HttpReadAloudService : BaseReadAloudService(), override fun onPrepared(mp: MediaPlayer?) { mp?.start() + super.play() } override fun onError(mp: MediaPlayer?, what: Int, extra: Int): Boolean { diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index eef74c2fe..8c7e75dfb 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -7,7 +7,6 @@ import android.support.v4.media.session.PlaybackStateCompat import io.legado.app.R 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.utils.getPrefBoolean import io.legado.app.utils.getPrefInt @@ -67,9 +66,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener return } if (requestFocus()) { - upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) - postEvent(Bus.ALOUD_STATE, Status.PLAY) - upNotification() + super.play() for (i in nowSpeak until contentList.size) { if (i == 0) { speak(contentList[i], TextToSpeech.QUEUE_FLUSH, AppConst.APP_TAG + i)