|
|
@ -80,9 +80,6 @@ object AudioPlay { |
|
|
|
fun skipTo(context: Context, index: Int) { |
|
|
|
fun skipTo(context: Context, index: Int) { |
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
|
book?.let { book -> |
|
|
|
book?.let { book -> |
|
|
|
val isPlay = !AudioPlayService.pause |
|
|
|
|
|
|
|
pause(context) |
|
|
|
|
|
|
|
status = Status.STOP |
|
|
|
|
|
|
|
durChapterIndex = index |
|
|
|
durChapterIndex = index |
|
|
|
durPageIndex = 0 |
|
|
|
durPageIndex = 0 |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
@ -91,12 +88,10 @@ object AudioPlay { |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
} |
|
|
|
} |
|
|
|
if (isPlay) { |
|
|
|
|
|
|
|
play(context) |
|
|
|
play(context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun prev(context: Context) { |
|
|
|
fun prev(context: Context) { |
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
@ -104,7 +99,6 @@ object AudioPlay { |
|
|
|
if (book.durChapterIndex <= 0) { |
|
|
|
if (book.durChapterIndex <= 0) { |
|
|
|
return@let |
|
|
|
return@let |
|
|
|
} |
|
|
|
} |
|
|
|
pause(context) |
|
|
|
|
|
|
|
durChapterIndex-- |
|
|
|
durChapterIndex-- |
|
|
|
durPageIndex = 0 |
|
|
|
durPageIndex = 0 |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
@ -113,12 +107,10 @@ object AudioPlay { |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
} |
|
|
|
} |
|
|
|
if (AudioPlayService.isRun) { |
|
|
|
|
|
|
|
play(context) |
|
|
|
play(context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun next(context: Context) { |
|
|
|
fun next(context: Context) { |
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
@ -126,7 +118,6 @@ object AudioPlay { |
|
|
|
if (book.durChapterIndex >= book.totalChapterNum) { |
|
|
|
if (book.durChapterIndex >= book.totalChapterNum) { |
|
|
|
return@let |
|
|
|
return@let |
|
|
|
} |
|
|
|
} |
|
|
|
pause(context) |
|
|
|
|
|
|
|
durChapterIndex++ |
|
|
|
durChapterIndex++ |
|
|
|
durPageIndex = 0 |
|
|
|
durPageIndex = 0 |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
|
book.durChapterIndex = durChapterIndex |
|
|
@ -135,12 +126,10 @@ object AudioPlay { |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
postEvent(EventBus.AUDIO_SUB_TITLE, chapter.title) |
|
|
|
} |
|
|
|
} |
|
|
|
if (AudioPlayService.isRun) { |
|
|
|
|
|
|
|
play(context) |
|
|
|
play(context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun saveRead() { |
|
|
|
fun saveRead() { |
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
|