mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
properly play OTG videos
This commit is contained in:
parent
66993d784e
commit
c25513fbcf
3 changed files with 9 additions and 10 deletions
|
@ -24,7 +24,6 @@ import com.bumptech.glide.request.target.Target
|
|||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.PhotoActivity
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
|
@ -205,7 +204,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
private fun loadGif() {
|
||||
try {
|
||||
val pathToLoad = getPathToLoad()
|
||||
val pathToLoad = getPathToLoad(medium)
|
||||
gifDrawable = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
||||
GifDrawable(context!!.contentResolver, Uri.parse(pathToLoad))
|
||||
} else {
|
||||
|
@ -243,7 +242,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(getPathToLoad())
|
||||
.load(getPathToLoad(medium))
|
||||
.apply(options)
|
||||
.listener(object : RequestListener<Bitmap> {
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean) = false
|
||||
|
@ -261,7 +260,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(getPathToLoad())
|
||||
.load(getPathToLoad(medium))
|
||||
.thumbnail(0.2f)
|
||||
.apply(options)
|
||||
.into(view.gif_view)
|
||||
|
@ -275,7 +274,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
maxScale = 10f
|
||||
beVisible()
|
||||
isQuickScaleEnabled = context.config.oneFingerZoom
|
||||
setImage(ImageSource.uri(getPathToLoad()))
|
||||
setImage(ImageSource.uri(getPathToLoad(medium)))
|
||||
orientation = if (imageOrientation == -1) SubsamplingScaleImageView.ORIENTATION_USE_EXIF else degreesForRotation(imageOrientation)
|
||||
setEagerLoadingEnabled(false)
|
||||
setExecutor(AsyncTask.SERIAL_EXECUTOR)
|
||||
|
@ -310,8 +309,6 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getPathToLoad() = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
||||
|
||||
private fun getImageOrientation(): Int {
|
||||
val defaultOrientation = -1
|
||||
var orient = defaultOrientation
|
||||
|
|
|
@ -183,7 +183,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
private fun initTimeHolder() {
|
||||
val res = resources
|
||||
val height = context!!.navigationBarHeight
|
||||
val left = mTimeHolder!!.paddingLeft
|
||||
val top = mTimeHolder!!.paddingTop
|
||||
var right = mTimeHolder!!.paddingRight
|
||||
|
@ -315,7 +314,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
return
|
||||
}
|
||||
|
||||
val mediumPath = if (wasEncoded) mEncodedPath else medium.path
|
||||
val mediumPath = if (wasEncoded) mEncodedPath else getPathToLoad(medium)
|
||||
try {
|
||||
mMediaPlayer = MediaPlayer().apply {
|
||||
setDataSource(context, Uri.parse(mediumPath))
|
||||
|
@ -327,7 +326,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
prepare()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
mEncodedPath = Uri.encode(medium.path)
|
||||
mEncodedPath = Uri.encode(getPathToLoad(medium))
|
||||
if (wasEncoded) {
|
||||
releaseMediaPlayer()
|
||||
} else {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.fragments
|
|||
|
||||
import android.support.v4.app.Fragment
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -65,4 +66,6 @@ abstract class ViewPagerFragment : Fragment() {
|
|||
}
|
||||
return details.toString().trim()
|
||||
}
|
||||
|
||||
fun getPathToLoad(medium: Medium) = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue