diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 4306289c3..c7a1de603 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -744,18 +744,18 @@ class PhotoFragment : ViewPagerFragment() { } private fun checkIfPanorama() { - mIsPanorama = try { - val inputStream = if (mMedium.path.startsWith("content:/")) { + mIsPanorama = try { + if (mMedium.path.startsWith("content:/")) { requireContext().contentResolver.openInputStream(Uri.parse(mMedium.path)) } else { File(mMedium.path).inputStream() + }.use { + val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(it, mMedium.name), HashMap()) + imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || + imageParser.contains("True", true) || + imageParser.contains("GPano:FullPanoWidthPixels=") || + imageParser.contains("GPano:ProjectionType>Equirectangular") } - - val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap()) - imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || - imageParser.contains("True", true) || - imageParser.contains("GPano:FullPanoWidthPixels=") || - imageParser.contains("GPano:ProjectionType>Equirectangular") } catch (e: Exception) { false } catch (e: OutOfMemoryError) { 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 1464938b6..c4cc359a9 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 @@ -364,6 +364,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S try { fileDataSource.open(dataSpec) } catch (e: Exception) { + fileDataSource.close() activity?.showErrorToast(e) return } @@ -372,6 +373,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S val mediaSource: MediaSource = ProgressiveMediaSource.Factory(factory) .createMediaSource(MediaItem.fromUri(fileDataSource.uri!!)) + fileDataSource.close() + mPlayOnPrepared = true mExoPlayer = ExoPlayer.Builder(requireContext())