|
|
@ -11,6 +11,7 @@ import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
|
|
|
|
import io.legado.app.service.help.AudioPlay |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
|
|
|
|
|
|
@ -183,6 +184,19 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun moveToNext() { |
|
|
|
|
|
|
|
if (durChapterIndex < chapterSize - 1) { |
|
|
|
|
|
|
|
durChapterIndex++ |
|
|
|
|
|
|
|
bookData.value?.let { |
|
|
|
|
|
|
|
it.durChapterIndex = durChapterIndex |
|
|
|
|
|
|
|
saveRead(it) |
|
|
|
|
|
|
|
loadContent(it, durChapterIndex) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
AudioPlay.stop(context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun saveRead(book: Book? = bookData.value) { |
|
|
|
fun saveRead(book: Book? = bookData.value) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
book?.let { book -> |
|
|
|
book?.let { book -> |
|
|
|