pull/49/head
kunfei 5 years ago
parent 4e434177c9
commit 9b4cae3921
  1. 5
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  2. 3
      app/src/main/java/io/legado/app/service/help/AudioPlay.kt
  3. 14
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt

@ -163,9 +163,12 @@ class AudioPlayService : BaseService(),
}
private fun upSpeed() {
kotlin.runCatching {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (mediaPlayer.isPlaying) {
mediaPlayer.playbackParams = mediaPlayer.playbackParams.setSpeed(AudioPlay.speed)
mediaPlayer.playbackParams =
mediaPlayer.playbackParams.setSpeed(AudioPlay.speed)
}
}
}
}

@ -52,10 +52,11 @@ object AudioPlay {
}
}
fun adjustSpeed(context: Context) {
fun adjustSpeed(context: Context, adjust: Float) {
if (AudioPlayService.isRun) {
val intent = Intent(context, AudioPlayService::class.java)
intent.action = Action.adjustSpeed
intent.putExtra("adjust", adjust)
context.startService(intent)
}
}

@ -87,20 +87,10 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
iv_fast_forward.invisible()
}
iv_fast_forward.onClick {
AudioPlay.speed = AudioPlay.speed + 0.1f
tv_speed.text = AudioPlay.speed.toString()
if (AudioPlay.speed == 1f) {
tv_speed.invisible()
} else {
tv_speed.visible()
}
AudioPlay.adjustSpeed(this)
AudioPlay.adjustSpeed(this, 0.1f)
}
iv_fast_rewind.onClick {
if (AudioPlay.speed > 0.5f) {
AudioPlay.speed = AudioPlay.speed - 0.1f
}
AudioPlay.adjustSpeed(this)
AudioPlay.adjustSpeed(this, -0.1f)
}
}

Loading…
Cancel
Save