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