From 6fd5fe26cacd07b510f30c916a2d1cb6d31b59a3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 Nov 2019 09:59:00 +0800 Subject: [PATCH] up --- .../java/io/legado/app/constant/Action.kt | 1 + .../io/legado/app/service/help/AudioPlay.kt | 8 ++++++ .../legado/app/ui/audio/AudioPlayActivity.kt | 28 +++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/Action.kt b/app/src/main/java/io/legado/app/constant/Action.kt index edccff54c..3a73365d2 100644 --- a/app/src/main/java/io/legado/app/constant/Action.kt +++ b/app/src/main/java/io/legado/app/constant/Action.kt @@ -11,4 +11,5 @@ object Action { const val prevParagraph = "prevParagraph" const val nextParagraph = "nextParagraph" const val upTtsSpeechRate = "upTtsSpeechRate" + const val upProgress = "upProgress" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt index 763d6a347..fefd33dab 100644 --- a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt +++ b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt @@ -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) + } + } } \ 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 8a9fd950c..cc31b3890 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 @@ -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(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) {