|
|
@ -92,24 +92,22 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
intent?.action?.let { action -> |
|
|
|
when (intent?.action) { |
|
|
|
when (action) { |
|
|
|
IntentAction.play -> { |
|
|
|
IntentAction.play -> { |
|
|
|
textChapter = ReadBook.curTextChapter |
|
|
|
textChapter = ReadBook.curTextChapter |
|
|
|
pageIndex = ReadBook.durPageIndex() |
|
|
|
pageIndex = ReadBook.durPageIndex() |
|
|
|
newReadAloud( |
|
|
|
newReadAloud( |
|
|
|
intent.getBooleanExtra("play", true) |
|
|
|
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() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
return super.onStartCommand(intent, flags, startId) |
|
|
|
} |
|
|
|
} |
|
|
@ -158,8 +156,12 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
@CallSuper |
|
|
|
@CallSuper |
|
|
|
open fun resumeReadAloud() { |
|
|
|
open fun resumeReadAloud() { |
|
|
|
pause = false |
|
|
|
pause = false |
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) |
|
|
|
if (contentList.isEmpty()) { |
|
|
|
postEvent(EventBus.ALOUD_STATE, Status.PLAY) |
|
|
|
ReadBook.readAloud() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) |
|
|
|
|
|
|
|
postEvent(EventBus.ALOUD_STATE, Status.PLAY) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract fun upSpeechRate(reset: Boolean = false) |
|
|
|
abstract fun upSpeechRate(reset: Boolean = false) |
|
|
|