From 2b3223be0845734e6ba8cf30c7107fe5548a34c6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 20 Nov 2017 21:53:55 +0100 Subject: [PATCH] use encoded video path only at passing it to the mediaplayer --- .../simplemobiletools/gallery/fragments/VideoFragment.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 423ecd1ea..f4b7f4b67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -47,6 +47,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private var mStoredExtendedDetails = 0 private var mCurrTime = 0 private var mDuration = 0 + private var mEncodedPath = "" private var mTouchDownX = 0f private var mTouchDownY = 0f @@ -416,9 +417,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee return } + val mediumPath = if (wasEncoded) mEncodedPath else medium.path try { mMediaPlayer = MediaPlayer().apply { - setDataSource(context, Uri.parse(medium.path)) + setDataSource(context, Uri.parse(mediumPath)) setDisplay(mSurfaceHolder) setOnCompletionListener { videoCompleted() } setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) @@ -427,7 +429,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee prepare() } } catch (e: IOException) { - medium.path = Uri.encode(medium.path) + mEncodedPath = Uri.encode(medium.path) if (wasEncoded) { releaseMediaPlayer() } else {