优化,修复在线朗读遇到单行标点时停止朗读的bug
This commit is contained in:
@@ -224,11 +224,9 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
/**
|
/**
|
||||||
* 当前页数
|
* 当前页数
|
||||||
*/
|
*/
|
||||||
fun durPageIndex(): Int {
|
val durPageIndex: Int
|
||||||
curTextChapter?.let {
|
get() {
|
||||||
return it.getPageIndexByCharIndex(durChapterPos)
|
return curTextChapter?.getPageIndexByCharIndex(durChapterPos) ?: durChapterPos
|
||||||
}
|
|
||||||
return durChapterPos
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
when (intent?.action) {
|
when (intent?.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)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -110,15 +110,11 @@ class HttpReadAloudService : BaseReadAloudService(),
|
|||||||
clearSpeakCache()
|
clearSpeakCache()
|
||||||
removeCacheFile()
|
removeCacheFile()
|
||||||
val httpTts = ReadAloud.httpTTS ?: return@execute
|
val httpTts = ReadAloud.httpTTS ?: return@execute
|
||||||
contentList.forEachIndexed { index, item ->
|
contentList.forEachIndexed { index, content ->
|
||||||
ensureActive()
|
ensureActive()
|
||||||
val speakText = item.replace(AppPattern.notReadAloudRegex, "")
|
|
||||||
val fileName =
|
val fileName =
|
||||||
md5SpeakFileName(
|
md5SpeakFileName(httpTts.url, AppConfig.ttsSpeechRate.toString(), content)
|
||||||
httpTts.url,
|
val speakText = content.replace(AppPattern.notReadAloudRegex, "")
|
||||||
AppConfig.ttsSpeechRate.toString(),
|
|
||||||
speakText
|
|
||||||
)
|
|
||||||
if (hasSpeakFile(fileName)) { //已经下载好的语音缓存
|
if (hasSpeakFile(fileName)) { //已经下载好的语音缓存
|
||||||
if (index == nowSpeak) {
|
if (index == nowSpeak) {
|
||||||
val file = getSpeakFileAsMd5(fileName)
|
val file = getSpeakFileAsMd5(fileName)
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
R.id.menu_download -> showDownloadDialog()
|
R.id.menu_download -> showDownloadDialog()
|
||||||
R.id.menu_add_bookmark -> {
|
R.id.menu_add_bookmark -> {
|
||||||
val book = ReadBook.book
|
val book = ReadBook.book
|
||||||
val page = ReadBook.curTextChapter?.page(ReadBook.durPageIndex())
|
val page = ReadBook.curTextChapter?.page(ReadBook.durPageIndex)
|
||||||
if (book != null && page != null) {
|
if (book != null && page != null) {
|
||||||
val bookmark = book.createBookMark().apply {
|
val bookmark = book.createBookMark().apply {
|
||||||
chapterIndex = ReadBook.durChapterIndex
|
chapterIndex = ReadBook.durChapterIndex
|
||||||
@@ -657,7 +657,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
launch {
|
launch {
|
||||||
autoPageProgress = 0
|
autoPageProgress = 0
|
||||||
binding.readView.upContent(relativePosition, resetPageOffset)
|
binding.readView.upContent(relativePosition, resetPageOffset)
|
||||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex())
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
||||||
loadStates = false
|
loadStates = false
|
||||||
success?.invoke()
|
success?.invoke()
|
||||||
}
|
}
|
||||||
@@ -675,7 +675,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun pageChanged() {
|
override fun pageChanged() {
|
||||||
launch {
|
launch {
|
||||||
autoPageProgress = 0
|
autoPageProgress = 0
|
||||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex())
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
||||||
startBackupJob()
|
startBackupJob()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
binding.tvChapterUrl.gone()
|
binding.tvChapterUrl.gone()
|
||||||
}
|
}
|
||||||
binding.seekReadPage.max = it.pageSize.minus(1)
|
binding.seekReadPage.max = it.pageSize.minus(1)
|
||||||
binding.seekReadPage.progress = ReadBook.durPageIndex()
|
binding.seekReadPage.progress = ReadBook.durPageIndex
|
||||||
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
||||||
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
||||||
} ?: let {
|
} ?: let {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter
|
|||||||
|
|
||||||
interface DataSource {
|
interface DataSource {
|
||||||
|
|
||||||
val pageIndex: Int get() = ReadBook.durPageIndex()
|
val pageIndex: Int get() = ReadBook.durPageIndex
|
||||||
|
|
||||||
val currentChapter: TextChapter?
|
val currentChapter: TextChapter?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user