diff --git a/app/src/main/java/io/legado/app/constant/Bus.kt b/app/src/main/java/io/legado/app/constant/Bus.kt index 4ebc61a08..115b49f92 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -15,4 +15,5 @@ object Bus { const val REPLACE = "replace" const val AUDIO_NEXT = "audioNext" const val AUDIO_CUR_POS = "audioCurPos" + const val AUDIO_STATE = "audioState" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt index 7f2386018..8a9fd950c 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.Bus +import io.legado.app.constant.Status import io.legado.app.data.entities.BookChapter import io.legado.app.service.help.AudioPlay import io.legado.app.utils.getViewModel @@ -18,6 +19,8 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a override val viewModel: AudioPlayViewModel get() = getViewModel(AudioPlayViewModel::class.java) + private var status = Status.STOP + override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) viewModel.initData(intent) @@ -47,7 +50,13 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a override fun observeLiveBus() { observeEvent(Bus.AUDIO_NEXT) { - + viewModel.durChapterIndex = viewModel.durChapterIndex + 1 + viewModel.bookData.value?.let { + viewModel.loadContent(it, viewModel.durChapterIndex) + } + } + observeEvent(Bus.AUDIO_STATE) { + status = it } } } \ No newline at end of file