|
|
|
@ -9,7 +9,6 @@ import io.legado.app.data.entities.Book |
|
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
|
import io.legado.app.model.WebBook |
|
|
|
|
import io.legado.app.service.AudioPlayService |
|
|
|
|
import io.legado.app.service.help.AudioPlay |
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
@ -18,9 +17,10 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) |
|
|
|
|
|
|
|
|
|
fun initData(intent: Intent) { |
|
|
|
|
execute { |
|
|
|
|
if (!AudioPlayService.isRun) { |
|
|
|
|
val bookUrl = intent.getStringExtra("bookUrl") |
|
|
|
|
if (AudioPlay.book?.bookUrl != bookUrl) { |
|
|
|
|
AudioPlay.stop(context) |
|
|
|
|
AudioPlay.inBookshelf = intent.getBooleanExtra("inBookshelf", true) |
|
|
|
|
val bookUrl = intent.getStringExtra("bookUrl") |
|
|
|
|
AudioPlay.book = if (!bookUrl.isNullOrEmpty()) { |
|
|
|
|
App.db.bookDao().getBook(bookUrl) |
|
|
|
|
} else { |
|
|
|
|