Fixed skip button not disappearing (#4072)

Co-authored-by: general-a <404aaronm@gmail.com>
This commit is contained in:
Bnyro 2023-06-23 14:04:58 +02:00 committed by GitHub
parent deef9a0c49
commit ad4d477834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -459,6 +459,17 @@ object PlayerHelper {
return null
}
fun ExoPlayer.isInSegment(
segments: List<Segment>
): 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
*/

View File

@ -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() {