|
|
@ -100,13 +100,11 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
|
|
|
|
|
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
when (intent?.action) { |
|
|
|
when (intent?.action) { |
|
|
|
IntentAction.play -> { |
|
|
|
IntentAction.play -> newReadAloud( |
|
|
|
textChapter = ReadBook.curTextChapter |
|
|
|
intent.getBooleanExtra("play", true), |
|
|
|
pageIndex = intent.getIntExtra("pageIndex", ReadBook.durPageIndex) |
|
|
|
intent.getIntExtra("pageIndex", ReadBook.durPageIndex), |
|
|
|
newReadAloud( |
|
|
|
intent.getIntExtra("startPos", 0) |
|
|
|
intent.getBooleanExtra("play", true) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
IntentAction.pause -> pauseReadAloud(true) |
|
|
|
IntentAction.pause -> pauseReadAloud(true) |
|
|
|
IntentAction.resume -> resumeReadAloud() |
|
|
|
IntentAction.resume -> resumeReadAloud() |
|
|
|
IntentAction.upTtsSpeechRate -> upSpeechRate(true) |
|
|
|
IntentAction.upTtsSpeechRate -> upSpeechRate(true) |
|
|
@ -119,11 +117,11 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
return super.onStartCommand(intent, flags, startId) |
|
|
|
return super.onStartCommand(intent, flags, startId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@CallSuper |
|
|
|
private fun newReadAloud(play: Boolean, pageIndex: Int, startPos: Int) { |
|
|
|
open fun newReadAloud(play: Boolean) { |
|
|
|
textChapter = ReadBook.curTextChapter |
|
|
|
textChapter?.let { textChapter -> |
|
|
|
textChapter?.let { textChapter -> |
|
|
|
nowSpeak = 0 |
|
|
|
nowSpeak = 0 |
|
|
|
readAloudNumber = textChapter.getReadLength(pageIndex) |
|
|
|
readAloudNumber = textChapter.getReadLength(pageIndex) + startPos |
|
|
|
contentList.clear() |
|
|
|
contentList.clear() |
|
|
|
if (getPrefBoolean(PreferKey.readAloudByPage)) { |
|
|
|
if (getPrefBoolean(PreferKey.readAloudByPage)) { |
|
|
|
for (index in pageIndex..textChapter.lastIndex) { |
|
|
|
for (index in pageIndex..textChapter.lastIndex) { |
|
|
|