diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 7fbafb70f..ce78ad075 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -25,7 +25,6 @@ import com.google.android.exoplayer2.upstream.DataSource import com.google.android.exoplayer2.upstream.DataSpec import com.google.android.exoplayer2.video.VideoListener import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* @@ -624,11 +623,11 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen } private fun releaseExoPlayer() { - mExoPlayer?.stop() - ensureBackgroundThread { - mExoPlayer?.release() - mExoPlayer = null + mExoPlayer?.apply { + stop() + release() } + mExoPlayer = null } override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { @@ -660,9 +659,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) { - ensureBackgroundThread { - mExoPlayer?.setVideoSurface(Surface(video_surface!!.surfaceTexture)) - } + mExoPlayer?.setVideoSurface(Surface(video_surface!!.surfaceTexture)) } override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {} 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 f204c09dd..470c6e86e 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 @@ -753,11 +753,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S private fun releaseExoPlayer() { mIsPlayerPrepared = false - mExoPlayer?.stop() - ensureBackgroundThread { - mExoPlayer?.release() - mExoPlayer = null + mExoPlayer?.apply { + stop() + release() } + mExoPlayer = null } override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {} @@ -767,9 +767,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) { - ensureBackgroundThread { - mExoPlayer?.setVideoSurface(Surface(mTextureView.surfaceTexture)) - } + mExoPlayer?.setVideoSurface(Surface(mTextureView.surfaceTexture)) } private fun setVideoSize() {