pull/48/head
kunfei 5 years ago
parent 50f698c1c3
commit 08a563e7b3
  1. 8
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -110,7 +110,6 @@ class AudioPlayService : BaseService(),
} }
private fun play() { private fun play() {
postEvent(Bus.AUDIO_SUB_TITLE, subtitle)
upNotification() upNotification()
if (requestFocus()) { if (requestFocus()) {
try { try {
@ -230,6 +229,10 @@ class AudioPlayService : BaseService(),
if (addLoading(index)) { if (addLoading(index)) {
launch(IO) { launch(IO) {
App.db.bookChapterDao().getChapter(book.bookUrl, index)?.let { chapter -> App.db.bookChapterDao().getChapter(book.bookUrl, index)?.let { chapter ->
if (index == AudioPlay.durChapterIndex) {
subtitle = chapter.title
postEvent(Bus.AUDIO_SUB_TITLE, subtitle)
}
BookHelp.getContent(book, chapter)?.let { BookHelp.getContent(book, chapter)?.let {
contentLoadFinish(chapter, it) contentLoadFinish(chapter, it)
removeLoading(chapter.index) removeLoading(chapter.index)
@ -285,6 +288,7 @@ class AudioPlayService : BaseService(),
} }
private fun moveTo(index: Int) { private fun moveTo(index: Int) {
mediaPlayer.pause()
AudioPlay.durChapterIndex = index AudioPlay.durChapterIndex = index
AudioPlay.durPageIndex = 0 AudioPlay.durPageIndex = 0
AudioPlay.book?.durChapterIndex = AudioPlay.durChapterIndex AudioPlay.book?.durChapterIndex = AudioPlay.durChapterIndex
@ -329,7 +333,7 @@ class AudioPlayService : BaseService(),
} }
} }
fun saveProgress() { private fun saveProgress() {
launch(IO) { launch(IO) {
AudioPlay.book?.let { AudioPlay.book?.let {
App.db.bookDao().upProgress(it.bookUrl, AudioPlay.durPageIndex) App.db.bookDao().upProgress(it.bookUrl, AudioPlay.durPageIndex)

Loading…
Cancel
Save