diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt index 6fd7964e8..d40ab8ce7 100644 --- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt @@ -459,6 +459,17 @@ object PlayerHelper { return null } + fun ExoPlayer.isInSegment( + segments: List + ): Boolean { + for (segment in segments) { + val segmentStart = (segment.segment[0] * 1000f).toLong() + val segmentEnd = (segment.segment[1] * 1000f).toLong() + if (currentPosition in segmentStart..segmentEnd) { return true } + } + return false + } + /** * Show a dialog with the chapters provided, even if the list is empty */ diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index dc2a62206..5a556c730 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -81,6 +81,7 @@ import com.github.libretube.helpers.LocaleHelper import com.github.libretube.helpers.NavigationHelper import com.github.libretube.helpers.PlayerHelper import com.github.libretube.helpers.PlayerHelper.checkForSegments +import com.github.libretube.helpers.PlayerHelper.isInSegment import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.ProxyHelper @@ -668,10 +669,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.sbSkipBtn.visibility = View.VISIBLE binding.sbSkipBtn.setOnClickListener { exoPlayer.seekTo(segmentEnd) - binding.sbSkipBtn.visibility = View.GONE } return } + if (!exoPlayer.isInSegment(segments)) binding.sbSkipBtn.visibility = View.GONE } private fun playVideo() {