pull/46/head
kunfei 5 years ago
parent 6bcba7010b
commit 6fd5fe26ca
  1. 1
      app/src/main/java/io/legado/app/constant/Action.kt
  2. 8
      app/src/main/java/io/legado/app/service/help/AudioPlay.kt
  3. 28
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt

@ -11,4 +11,5 @@ object Action {
const val prevParagraph = "prevParagraph"
const val nextParagraph = "nextParagraph"
const val upTtsSpeechRate = "upTtsSpeechRate"
const val upProgress = "upProgress"
}

@ -41,4 +41,12 @@ object AudioPlay {
}
}
fun upProgress(context: Context, position: Int) {
if (AudioPlayService.isRun) {
val intent = Intent(context, AudioPlayService::class.java)
intent.action = Action.upProgress
intent.putExtra("position", position)
context.startService(intent)
}
}
}

@ -1,6 +1,7 @@
package io.legado.app.ui.audio
import android.os.Bundle
import android.widget.SeekBar
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus
@ -29,10 +30,33 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
private fun initView() {
fab_play_stop.onClick {
viewModel.bookData.value?.let {
viewModel.loadContent(it, viewModel.durChapterIndex)
when (status) {
Status.PLAY -> AudioPlay.pause(this)
Status.PAUSE -> AudioPlay.resume(this)
else -> viewModel.bookData.value?.let {
viewModel.loadContent(it, viewModel.durChapterIndex)
}
}
}
iv_skip_next.onClick {
}
iv_skip_previous.onClick {
}
player_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
AudioPlay.upProgress(this@AudioPlayActivity, player_progress.progress)
}
})
}
override fun contentLoadFinish(bookChapter: BookChapter, content: String) {

Loading…
Cancel
Save