fix loading bar and app switching

Changelog: changed
This commit is contained in:
Kai 2025-04-09 12:16:07 -05:00
parent 81162c5df2
commit 9a435f8859
No known key found for this signature in database
2 changed files with 7 additions and 19 deletions

View File

@ -190,12 +190,8 @@ class ShortsFragment : MainFragment() {
customViewAdapter?.previousShownView?.pause() customViewAdapter?.previousShownView?.pause()
} }
override fun onResume() { override fun onDestroy() {
super.onResume() super.onDestroy()
}
override fun onStop() {
super.onStop()
customViewAdapter?.previousShownView?.stop() customViewAdapter?.previousShownView?.stop()
} }

View File

@ -39,6 +39,7 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
Player.EVENT_POSITION_DISCONTINUITY, Player.EVENT_IS_PLAYING_CHANGED, Player.EVENT_PLAYBACK_STATE_CHANGED Player.EVENT_POSITION_DISCONTINUITY, Player.EVENT_IS_PLAYING_CHANGED, Player.EVENT_PLAYBACK_STATE_CHANGED
) )
) { ) {
progressAnimator.cancel()
if (player.duration >= 0) { if (player.duration >= 0) {
progressAnimator.duration = player.duration progressAnimator.duration = player.duration
setProgressBarDuration(player.duration) setProgressBarDuration(player.duration)
@ -46,15 +47,7 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
} }
if (player.isPlaying) { if (player.isPlaying) {
if (progressAnimator.isPaused) { progressAnimator.start()
progressAnimator.resume()
} else if (!progressAnimator.isStarted) {
progressAnimator.start()
}
} else {
if (progressAnimator.isRunning) {
progressAnimator.pause()
}
} }
} }
} }
@ -72,9 +65,7 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
progressBar.addListener(object : TimeBar.OnScrubListener { progressBar.addListener(object : TimeBar.OnScrubListener {
override fun onScrubStart(timeBar: TimeBar, position: Long) { override fun onScrubStart(timeBar: TimeBar, position: Long) {
if (progressAnimator.isRunning) { progressAnimator.cancel()
progressAnimator.pause()
}
} }
override fun onScrubMove(timeBar: TimeBar, position: Long) {} override fun onScrubMove(timeBar: TimeBar, position: Long) {}
@ -82,7 +73,8 @@ class FutoShortPlayer(context: Context, attrs: AttributeSet? = null) :
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) { override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {
if (canceled) { if (canceled) {
progressAnimator.currentPlayTime = player.player.currentPosition progressAnimator.currentPlayTime = player.player.currentPosition
progressAnimator.resume() progressAnimator.duration = player.player.duration
progressAnimator.start()
return return
} }