From 2c70845c06793b6bc68e8dd2991fcbc63fe2ca4a Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 19 Jan 2022 17:12:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/defaultData/directLinkUpload.json | 4 +- .../app/service/BaseReadAloudService.kt | 40 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/src/main/assets/defaultData/directLinkUpload.json b/app/src/main/assets/defaultData/directLinkUpload.json index 299e5e589..9fd9308f0 100644 --- a/app/src/main/assets/defaultData/directLinkUpload.json +++ b/app/src/main/assets/defaultData/directLinkUpload.json @@ -1,5 +1,5 @@ { - "UploadUrl": "http://sy.miaogongzi.cc/shuyuan,{\"method\":\"POST\",\"body\": {\"file\": \"fileRequest\"},\"type\": \"multipart/form-data\"}", - "DownloadUrlRule": "$.data@js:if (result == '') \n '' \n else \n 'https://shuyuan.miaogongzi.cc/shuyuan/' + result", + "UploadUrl": "http://sy.mgz6.cc/shuyuan,{\"method\":\"POST\",\"body\": {\"file\": \"fileRequest\"},\"type\": \"multipart/form-data\"}", + "DownloadUrlRule": "$.data@js:if (result == '') \n '' \n else \n 'https://shuyuan.mgz6.cc/shuyuan/' + result", "summary": "有效期2天" } \ No newline at end of file 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 b1e1bb324..46adde993 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -92,24 +92,22 @@ abstract class BaseReadAloudService : BaseService(), } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - intent?.action?.let { action -> - when (action) { - IntentAction.play -> { - textChapter = ReadBook.curTextChapter - pageIndex = ReadBook.durPageIndex() - newReadAloud( - intent.getBooleanExtra("play", true) - ) - } - IntentAction.pause -> pauseReadAloud(true) - IntentAction.resume -> resumeReadAloud() - IntentAction.upTtsSpeechRate -> upSpeechRate(true) - IntentAction.prevParagraph -> prevP() - IntentAction.nextParagraph -> nextP() - IntentAction.addTimer -> addTimer() - IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0)) - else -> stopSelf() + when (intent?.action) { + IntentAction.play -> { + textChapter = ReadBook.curTextChapter + pageIndex = ReadBook.durPageIndex() + newReadAloud( + intent.getBooleanExtra("play", true) + ) } + IntentAction.pause -> pauseReadAloud(true) + IntentAction.resume -> resumeReadAloud() + IntentAction.upTtsSpeechRate -> upSpeechRate(true) + IntentAction.prevParagraph -> prevP() + IntentAction.nextParagraph -> nextP() + IntentAction.addTimer -> addTimer() + IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0)) + else -> stopSelf() } return super.onStartCommand(intent, flags, startId) } @@ -158,8 +156,12 @@ abstract class BaseReadAloudService : BaseService(), @CallSuper open fun resumeReadAloud() { pause = false - upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) - postEvent(EventBus.ALOUD_STATE, Status.PLAY) + if (contentList.isEmpty()) { + ReadBook.readAloud() + } else { + upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + postEvent(EventBus.ALOUD_STATE, Status.PLAY) + } } abstract fun upSpeechRate(reset: Boolean = false)