use encoded video path only at passing it to the mediaplayer

This commit is contained in:
tibbi 2017-11-20 21:53:55 +01:00
parent 03be5504f4
commit 2b3223be08
1 changed files with 4 additions and 2 deletions

View File

@ -47,6 +47,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
private var mStoredExtendedDetails = 0 private var mStoredExtendedDetails = 0
private var mCurrTime = 0 private var mCurrTime = 0
private var mDuration = 0 private var mDuration = 0
private var mEncodedPath = ""
private var mTouchDownX = 0f private var mTouchDownX = 0f
private var mTouchDownY = 0f private var mTouchDownY = 0f
@ -416,9 +417,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
return return
} }
val mediumPath = if (wasEncoded) mEncodedPath else medium.path
try { try {
mMediaPlayer = MediaPlayer().apply { mMediaPlayer = MediaPlayer().apply {
setDataSource(context, Uri.parse(medium.path)) setDataSource(context, Uri.parse(mediumPath))
setDisplay(mSurfaceHolder) setDisplay(mSurfaceHolder)
setOnCompletionListener { videoCompleted() } setOnCompletionListener { videoCompleted() }
setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() })
@ -427,7 +429,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
prepare() prepare()
} }
} catch (e: IOException) { } catch (e: IOException) {
medium.path = Uri.encode(medium.path) mEncodedPath = Uri.encode(medium.path)
if (wasEncoded) { if (wasEncoded) {
releaseMediaPlayer() releaseMediaPlayer()
} else { } else {