fixing some video playback glitches
This commit is contained in:
parent
ee6d283c96
commit
d1d2be6483
|
@ -49,8 +49,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
private var mIsPlaying = false
|
private var mIsPlaying = false
|
||||||
private var mIsDragged = false
|
private var mIsDragged = false
|
||||||
private var mWasVideoStarted = false
|
private var mWasVideoStarted = false
|
||||||
|
private var mWasPlayerInited = false
|
||||||
|
private var mWasLastPositionRestored = false
|
||||||
private var mCurrTime = 0
|
private var mCurrTime = 0
|
||||||
private var mDuration = 0
|
private var mDuration = 0
|
||||||
|
private var mPositionWhenInit = 0
|
||||||
|
|
||||||
private var mExoPlayer: SimpleExoPlayer? = null
|
private var mExoPlayer: SimpleExoPlayer? = null
|
||||||
private var mVideoSize = Point(0, 0)
|
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) {
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
if (mExoPlayer != null && fromUser) {
|
if (mExoPlayer != null && fromUser) {
|
||||||
|
if (!mWasPlayerInited) {
|
||||||
|
mPositionWhenInit = progress
|
||||||
|
}
|
||||||
setPosition(progress)
|
setPosition(progress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +559,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
setPosition(0)
|
setPosition(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredRememberLastVideoPosition) {
|
if (mStoredRememberLastVideoPosition && !mWasLastPositionRestored) {
|
||||||
|
mWasLastPositionRestored = true
|
||||||
restoreLastVideoSavedPosition()
|
restoreLastVideoSavedPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,6 +621,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
playVideo()
|
playVideo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPositionWhenInit != 0 && !mWasPlayerInited) {
|
||||||
|
setPosition(mPositionWhenInit)
|
||||||
|
mPositionWhenInit = 0
|
||||||
|
}
|
||||||
|
mWasPlayerInited = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun videoCompleted() {
|
private fun videoCompleted() {
|
||||||
|
|
Loading…
Reference in New Issue