|
|
@ -88,7 +88,7 @@ class AudioPlayService : BaseService(), |
|
|
|
Action.resume -> resume() |
|
|
|
Action.resume -> resume() |
|
|
|
Action.prev -> moveToPrev() |
|
|
|
Action.prev -> moveToPrev() |
|
|
|
Action.next -> moveToNext() |
|
|
|
Action.next -> moveToNext() |
|
|
|
Action.adjustSpeed -> upSpeed() |
|
|
|
Action.adjustSpeed -> upSpeed(intent.getFloatExtra("adjust", 1f)) |
|
|
|
Action.moveTo -> moveTo(intent.getIntExtra("index", AudioPlay.durChapterIndex)) |
|
|
|
Action.moveTo -> moveTo(intent.getIntExtra("index", AudioPlay.durChapterIndex)) |
|
|
|
Action.addTimer -> addTimer() |
|
|
|
Action.addTimer -> addTimer() |
|
|
|
Action.setTimer -> setTimer(intent.getIntExtra("minute", 0)) |
|
|
|
Action.setTimer -> setTimer(intent.getIntExtra("minute", 0)) |
|
|
@ -145,7 +145,6 @@ class AudioPlayService : BaseService(), |
|
|
|
pause = false |
|
|
|
pause = false |
|
|
|
mediaPlayer.start() |
|
|
|
mediaPlayer.start() |
|
|
|
mediaPlayer.seekTo(position) |
|
|
|
mediaPlayer.seekTo(position) |
|
|
|
upSpeed() |
|
|
|
|
|
|
|
handler.removeCallbacks(mpRunnable) |
|
|
|
handler.removeCallbacks(mpRunnable) |
|
|
|
handler.postDelayed(mpRunnable, 1000) |
|
|
|
handler.postDelayed(mpRunnable, 1000) |
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) |
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) |
|
|
@ -162,12 +161,14 @@ class AudioPlayService : BaseService(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upSpeed() { |
|
|
|
private fun upSpeed(adjust: Float) { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
|
if (mediaPlayer.isPlaying) { |
|
|
|
with(mediaPlayer) { |
|
|
|
mediaPlayer.playbackParams = |
|
|
|
if (isPlaying) { |
|
|
|
mediaPlayer.playbackParams.setSpeed(AudioPlay.speed) |
|
|
|
playbackParams = playbackParams.apply { speed += adjust } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
postEvent(Bus.AUDIO_SPEED, playbackParams.speed) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -181,7 +182,6 @@ class AudioPlayService : BaseService(), |
|
|
|
mp?.let { |
|
|
|
mp?.let { |
|
|
|
mp.start() |
|
|
|
mp.start() |
|
|
|
mp.seekTo(position) |
|
|
|
mp.seekTo(position) |
|
|
|
upSpeed() |
|
|
|
|
|
|
|
postEvent(Bus.AUDIO_SIZE, mp.duration) |
|
|
|
postEvent(Bus.AUDIO_SIZE, mp.duration) |
|
|
|
bookChapter?.let { |
|
|
|
bookChapter?.let { |
|
|
|
it.end = mp.duration.toLong() |
|
|
|
it.end = mp.duration.toLong() |
|
|
|