This commit is contained in:
Horis 2024-03-10 11:30:00 +08:00
parent 274ce5a6ea
commit f128df2d96
2 changed files with 15 additions and 3 deletions

View File

@ -201,6 +201,7 @@ object ReadBook : CoroutineScope by MainScope() {
val nextPagePos = it.getNextPageLength(durChapterPos) val nextPagePos = it.getNextPageLength(durChapterPos)
if (nextPagePos >= 0) { if (nextPagePos >= 0) {
hasNextPage = true hasNextPage = true
curTextChapter?.getPage(durPageIndex)?.removePageAloudSpan()
durChapterPos = nextPagePos durChapterPos = nextPagePos
callBack?.upContent() callBack?.upContent()
saveRead(true) saveRead(true)

View File

@ -36,6 +36,7 @@ import io.legado.app.model.ReadBook
import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.utils.LogUtils
import io.legado.app.utils.activityPendingIntent import io.legado.app.utils.activityPendingIntent
import io.legado.app.utils.broadcastPendingIntent import io.legado.app.utils.broadcastPendingIntent
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefBoolean
@ -77,6 +78,8 @@ abstract class BaseReadAloudService : BaseService(),
return isRun && !pause return isRun && !pause
} }
private const val TAG = "BaseReadAloudService"
} }
private val useWakeLock = appCtx.getPrefBoolean(PreferKey.readAloudWakeLock, false) private val useWakeLock = appCtx.getPrefBoolean(PreferKey.readAloudWakeLock, false)
@ -88,9 +91,10 @@ abstract class BaseReadAloudService : BaseService(),
} }
private val wifiLock by lazy { private val wifiLock by lazy {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
wifiManager?.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "legado:AudioPlayService")?.apply { wifiManager?.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "legado:AudioPlayService")
setReferenceCounted(false) ?.apply {
} setReferenceCounted(false)
}
} }
private val mFocusRequest: AudioFocusRequestCompat by lazy { private val mFocusRequest: AudioFocusRequestCompat by lazy {
MediaHelp.buildAudioFocusRequestCompat(this) MediaHelp.buildAudioFocusRequestCompat(this)
@ -212,6 +216,13 @@ abstract class BaseReadAloudService : BaseService(),
} }
} }
nowSpeak = textChapter.getParagraphNum(readAloudNumber + 1, readAloudByPage) - 1 nowSpeak = textChapter.getParagraphNum(readAloudNumber + 1, readAloudByPage) - 1
if (nowSpeak < 0) {
LogUtils.d(TAG) {
"nowSpeak:$nowSpeak readAloudNumber:$readAloudNumber isCompleted:${textChapter.isCompleted} " +
"pageSize:${textChapter.pageSize} \np1:${textChapter.paragraphsInternal}\n" +
"p2:${textChapter.pageParagraphsInternal}"
}
}
if (!readAloudByPage && startPos == 0 && !toLast) { if (!readAloudByPage && startPos == 0 && !toLast) {
pos = page.lines.first().chapterPosition - pos = page.lines.first().chapterPosition -
textChapter.paragraphs[nowSpeak].chapterPosition textChapter.paragraphs[nowSpeak].chapterPosition