File tree Expand file tree Collapse file tree
app/src/main/java/remix/myplayer/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -791,19 +791,15 @@ class MusicService : BaseService(),
791791 */
792792 private fun skipToNext () {
793793 playback.skipToNext()
794- if (! playback.isPlaying) {
795- playback.start()
796- }
794+ start(true )
797795 }
798796
799797 /* *
800798 * 播放上一首
801799 */
802800 private fun skipToPrevious () {
803801 playback.skipToPrevious()
804- if (! playback.isPlaying) {
805- playback.start()
806- }
802+ start(true )
807803 }
808804
809805 /* *
@@ -904,9 +900,7 @@ class MusicService : BaseService(),
904900 }
905901
906902 playback.skipTo(position)
907- if (! playback.isPlaying) {
908- playback.start()
909- }
903+ start(true )
910904 }
911905
912906 override fun onMediaStoreChanged () {
Original file line number Diff line number Diff line change 11package remix.myplayer.service
22
33import android.animation.Animator
4+ import android.animation.AnimatorListenerAdapter
45import android.animation.ValueAnimator
56import android.os.Handler
67import android.os.Looper
@@ -58,14 +59,22 @@ class VolumeController(private val service: MusicService) {
5859 service.playback.setVolume(volume)
5960 lastVolume = volume
6061 }
61- if (onEnd != null ) {
62- addListener(object : Animator .AnimatorListener {
63- override fun onAnimationStart (animation : Animator ) = Unit
64- override fun onAnimationEnd (animation : Animator ) = onEnd()
65- override fun onAnimationCancel (animation : Animator ) = Unit
66- override fun onAnimationRepeat (animation : Animator ) = Unit
67- })
68- }
62+ addListener(object : AnimatorListenerAdapter () {
63+ private var canceled = false
64+
65+ override fun onAnimationCancel (animation : Animator ) {
66+ canceled = true
67+ }
68+
69+ override fun onAnimationEnd (animation : Animator ) {
70+ if (animator == = animation) {
71+ animator = null
72+ }
73+ if (! canceled) {
74+ onEnd?.invoke()
75+ }
76+ }
77+ })
6978 }
7079 animator?.start()
7180 }
@@ -80,4 +89,4 @@ class VolumeController(private val service: MusicService) {
8089
8190 private const val DURATION_IN_MS = 400L
8291 }
83- }
92+ }
You can’t perform that action at this time.
0 commit comments