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 08500bfa6..67e6ee84e 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -16,4 +16,5 @@ object Bus { const val AUDIO_NEXT = "audioNext" const val AUDIO_STATE = "audioState" const val AUDIO_PROGRESS = "audioProgress" + const val AUDIO_SIZE = "audioSize" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 0a2c23e4d..e5c934d66 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -130,6 +130,7 @@ class AudioPlayService : BaseService(), override fun onPrepared(mp: MediaPlayer?) { if (pause) return mp?.start() + postEvent(Bus.AUDIO_PROGRESS, mp?.duration) } override fun onError(mp: MediaPlayer?, what: Int, extra: Int): Boolean { 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 be1819608..907df608d 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 @@ -23,6 +23,7 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a override val viewModel: AudioPlayViewModel get() = getViewModel(AudioPlayViewModel::class.java) + private var adjustProgress = false private var status = Status.STOP override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -55,10 +56,11 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a } override fun onStartTrackingTouch(seekBar: SeekBar?) { - + adjustProgress = true } override fun onStopTrackingTouch(seekBar: SeekBar?) { + adjustProgress = false AudioPlay.upProgress(this@AudioPlayActivity, player_progress.progress) } }) @@ -97,8 +99,10 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a status = it } observeEvent(Bus.AUDIO_PROGRESS) { - if (!player_progress.isInTouchMode) - player_progress.progress = it + if (!adjustProgress) player_progress.progress = it + } + observeEvent(Bus.AUDIO_SIZE) { + player_progress.max = it } } } \ No newline at end of file