diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 1f220e798..890654b1d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -49,8 +49,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S private var mIsPlaying = false private var mIsDragged = false private var mWasVideoStarted = false + private var mWasPlayerInited = false + private var mWasLastPositionRestored = false private var mCurrTime = 0 private var mDuration = 0 + private var mPositionWhenInit = 0 private var mExoPlayer: SimpleExoPlayer? = null private var mVideoSize = Point(0, 0) @@ -496,6 +499,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { if (mExoPlayer != null && fromUser) { + if (!mWasPlayerInited) { + mPositionWhenInit = progress + } setPosition(progress) } } @@ -553,7 +559,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S setPosition(0) } - if (mStoredRememberLastVideoPosition) { + if (mStoredRememberLastVideoPosition && !mWasLastPositionRestored) { + mWasLastPositionRestored = true restoreLastVideoSavedPosition() } @@ -614,6 +621,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S playVideo() } } + + if (mPositionWhenInit != 0 && !mWasPlayerInited) { + setPosition(mPositionWhenInit) + mPositionWhenInit = 0 + } + mWasPlayerInited = true } private fun videoCompleted() {