pull/46/head
kunfei 5 years ago
parent 60112a7ecb
commit ab7101c276
  1. 1
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 1
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  3. 10
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.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"
}

@ -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 {

@ -23,6 +23,7 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(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<AudioPlayViewModel>(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<AudioPlayViewModel>(R.layout.activity_a
status = it
}
observeEvent<Int>(Bus.AUDIO_PROGRESS) {
if (!player_progress.isInTouchMode)
player_progress.progress = it
if (!adjustProgress) player_progress.progress = it
}
observeEvent<Int>(Bus.AUDIO_SIZE) {
player_progress.max = it
}
}
}
Loading…
Cancel
Save