From a16bbfbcf9b1f2e17049988789f9889f4a22507a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Mar 2020 10:42:08 +0100 Subject: [PATCH] fix #1765, properly handle videos at slideshows --- .../gallery/pro/activities/PhotoVideoActivity.kt | 2 ++ .../gallery/pro/activities/ViewPagerActivity.kt | 2 ++ .../gallery/pro/fragments/VideoFragment.kt | 12 ++++++++---- .../gallery/pro/fragments/ViewPagerFragment.kt | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 9ea20f4a9..96dbc0fde 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -359,4 +359,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList override fun goToNextItem() {} override fun launchViewVideoIntent(path: String) {} + + override fun isSlideShowActive() = false } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 089d3da5d..cea66cd8e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -1185,6 +1185,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return mIsSlideshowActive } + override fun isSlideShowActive() = mIsSlideshowActive + override fun goToPrevItem() { view_pager.setCurrentItem(view_pager.currentItem - 1, false) checkOrientation() 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 3d663ec8b..4debc2c65 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 @@ -347,7 +347,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S mExoPlayer = ExoPlayerFactory.newSimpleInstance(context) mExoPlayer!!.seekParameters = SeekParameters.CLOSEST_SYNC - if (mConfig.loopVideos) { + if (mConfig.loopVideos && listener?.isSlideShowActive() == false) { mExoPlayer?.repeatMode = Player.REPEAT_MODE_ONE } @@ -722,9 +722,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } mCurrTime = (mExoPlayer!!.duration / 1000).toInt() - mSeekBar.progress = mSeekBar.max - mCurrTimeView.text = mDuration.getFormattedDuration() - pauseVideo() + if (listener?.videoEnded() == false && mConfig.loopVideos) { + playVideo() + } else { + mSeekBar.progress = mSeekBar.max + mCurrTimeView.text = mDuration.getFormattedDuration() + pauseVideo() + } } private fun cleanup() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt index ef017dbad..41a31afe3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt @@ -31,6 +31,8 @@ abstract class ViewPagerFragment : Fragment() { fun goToNextItem() fun launchViewVideoIntent(path: String) + + fun isSlideShowActive(): Boolean } fun getMediumExtendedDetails(medium: Medium): String {