use a background thread for fetching video durations

This commit is contained in:
tibbi 2020-05-04 10:25:34 +02:00
parent f0736fe634
commit a4c1da2ac6

View file

@ -330,7 +330,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
}
private fun setupTimer() {
activity!!.runOnUiThread(object : Runnable {
activity?.runOnUiThread(object : Runnable {
override fun run() {
if (mExoPlayer != null && !mIsDragged && mIsPlaying) {
mCurrTime = (mExoPlayer!!.currentPosition / 1000).toInt()
@ -687,9 +687,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
}
private fun setupVideoDuration() {
mDuration = mMedium.path.getVideoDuration()
setupTimeHolder()
setPosition(0)
ensureBackgroundThread {
mDuration = mMedium.path.getVideoDuration()
activity?.runOnUiThread {
setupTimeHolder()
setPosition(0)
}
}
}
private fun videoPrepared() {