从文字选择处开始朗读,未完成
This commit is contained in:
@@ -123,17 +123,11 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
nowSpeak = 0
|
nowSpeak = 0
|
||||||
readAloudNumber = textChapter.getReadLength(pageIndex) + startPos
|
readAloudNumber = textChapter.getReadLength(pageIndex) + startPos
|
||||||
contentList.clear()
|
contentList.clear()
|
||||||
if (getPrefBoolean(PreferKey.readAloudByPage)) {
|
val readAloudByPage = getPrefBoolean(PreferKey.readAloudByPage)
|
||||||
for (index in pageIndex..textChapter.lastIndex) {
|
textChapter.getNeedReadAloud(pageIndex, readAloudByPage, startPos)
|
||||||
textChapter.getPage(index)?.text?.split("\n")?.let {
|
.split("\n").forEach { text ->
|
||||||
contentList.addAll(it)
|
if (text.isNotEmpty()) {
|
||||||
}
|
contentList.add(text)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
textChapter.getUnRead(pageIndex).split("\n").forEach {
|
|
||||||
if (it.isNotEmpty()) {
|
|
||||||
contentList.add(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (play) play()
|
if (play) play()
|
||||||
|
|||||||
@@ -562,11 +562,17 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
|||||||
* 从选择位置开始朗读
|
* 从选择位置开始朗读
|
||||||
*/
|
*/
|
||||||
fun aloudStartSelect() {
|
fun aloudStartSelect() {
|
||||||
|
//todo 未完成
|
||||||
val selectStartPos = curPage.selectStartPos
|
val selectStartPos = curPage.selectStartPos
|
||||||
if (selectStartPos.relativePagePos > 0) {
|
curPage.textPage.textLines.forEach {
|
||||||
ReadBook.moveToNextPage()
|
|
||||||
}
|
}
|
||||||
//TODO 未完成
|
if (selectStartPos.relativePagePos > 0) {
|
||||||
|
if (!ReadBook.moveToNextPage()) {
|
||||||
|
ReadBook.moveToNextChapter(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReadAloud.play(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page.entities
|
|||||||
|
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
data class TextChapter(
|
data class TextChapter(
|
||||||
val position: Int,
|
val position: Int,
|
||||||
val title: String,
|
val title: String,
|
||||||
@@ -85,6 +86,26 @@ data class TextChapter(
|
|||||||
return stringBuilder.toString()
|
return stringBuilder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 需要朗读的文本列表
|
||||||
|
* @param pageIndex 起始页
|
||||||
|
* @param pageSplit 是否分页
|
||||||
|
* @param startPos 从当前页什么地方开始朗读
|
||||||
|
*/
|
||||||
|
fun getNeedReadAloud(pageIndex: Int, pageSplit: Boolean, startPos: Int): String {
|
||||||
|
//todo 未完成
|
||||||
|
val stringBuilder = StringBuilder()
|
||||||
|
if (pages.isNotEmpty()) {
|
||||||
|
for (index in pageIndex..pages.lastIndex) {
|
||||||
|
stringBuilder.append(pages[index].text)
|
||||||
|
if (pageSplit && !stringBuilder.endsWith("\n")) {
|
||||||
|
stringBuilder.append("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringBuilder.toString()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 根据索引位置获取所在页
|
* @return 根据索引位置获取所在页
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user