fixing some video playback glitches
This commit is contained in:
parent
ee6d283c96
commit
d1d2be6483
1 changed files with 14 additions and 1 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue