mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
Reset progress views on video loop
The previous loop method of seeking to the beginning at video completion ensured that the seekbar and current time text were immediately reset. Using ExoPlayer's own implementation of video looping means that `Player.STATE_ENDED` is no longer reached, thus the UI no longer accurately tracks progress. Restore the old behaviour by resetting the views on position discontinuity.
This commit is contained in:
parent
f8315438d8
commit
e83db406a9
2 changed files with 14 additions and 2 deletions
|
@ -234,7 +234,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
|
||||
override fun onLoadingChanged(isLoading: Boolean) {}
|
||||
|
||||
override fun onPositionDiscontinuity(reason: Int) {}
|
||||
override fun onPositionDiscontinuity(reason: Int) {
|
||||
// Reset progress views when video loops.
|
||||
if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION) {
|
||||
video_seekbar.progress = 0
|
||||
video_curr_time.text = 0.getFormattedDuration()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged(repeatMode: Int) {}
|
||||
|
||||
|
|
|
@ -353,7 +353,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
|
||||
override fun onLoadingChanged(isLoading: Boolean) {}
|
||||
|
||||
override fun onPositionDiscontinuity(reason: Int) {}
|
||||
override fun onPositionDiscontinuity(reason: Int) {
|
||||
// Reset progress views when video loops.
|
||||
if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION) {
|
||||
mSeekBar.progress = 0
|
||||
mCurrTimeView.text = 0.getFormattedDuration()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged(repeatMode: Int) {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue