diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
index 747346c5a..66a335d62 100644
--- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
+++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
@@ -75,6 +75,7 @@ object PreferenceKeys {
const val SKIP_BUTTONS = "skip_buttons"
const val PICTURE_IN_PICTURE = "picture_in_picture"
const val PLAYER_RESIZE_MODE = "player_resize_mode"
+ const val SB_SKIP_MANUALLY = "sb_skip_manually_key"
/**
* Background mode
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index a60ea1b94..f3637c1eb 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -169,6 +169,7 @@ class PlayerFragment : BaseFragment() {
private var sponsorBlockNotifications = true
private var skipButtonsEnabled = false
private var pipEnabled = true
+ private var skipSegmentsManually = false
/**
* for autoplay
@@ -336,6 +337,11 @@ class PlayerFragment : BaseFragment() {
PreferenceKeys.PICTURE_IN_PICTURE,
true
)
+
+ skipSegmentsManually = PreferenceHelper.getBoolean(
+ PreferenceKeys.SB_SKIP_MANUALLY,
+ false
+ )
}
@SuppressLint("ClickableViewAccessibility")
@@ -709,21 +715,39 @@ class PlayerFragment : BaseFragment() {
Handler(Looper.getMainLooper()).postDelayed(this::checkForSegments, 100)
- if (!::segmentData.isInitialized || segmentData.segments.isEmpty()) {
- return
- }
+ if (!::segmentData.isInitialized || segmentData.segments.isEmpty()) return
+ val currentPosition = exoPlayer.currentPosition
segmentData.segments.forEach { segment: Segment ->
val segmentStart = (segment.segment!![0] * 1000f).toLong()
val segmentEnd = (segment.segment[1] * 1000f).toLong()
- val currentPosition = exoPlayer.currentPosition
+
+ // show the button to manually skip the segment
if (currentPosition in segmentStart until segmentEnd) {
- if (sponsorBlockNotifications) {
- Toast.makeText(context, R.string.segment_skipped, Toast.LENGTH_SHORT).show()
+ if (skipSegmentsManually) {
+ binding.sbSkipBtn.visibility = View.VISIBLE
+ binding.sbSkipBtn.setOnClickListener {
+ exoPlayer.seekTo(segmentEnd)
+ }
+ return
}
+
+ if (sponsorBlockNotifications) {
+ Toast
+ .makeText(
+ context,
+ R.string.segment_skipped,
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+
+ // skip the segment automatically
exoPlayer.seekTo(segmentEnd)
+ return
}
}
+
+ if (skipSegmentsManually) binding.sbSkipBtn.visibility = View.GONE
}
private fun playVideo() {
@@ -743,6 +767,9 @@ class PlayerFragment : BaseFragment() {
}
runOnUiThread {
+ // hide the button to skip SponsorBlock segments manually
+ binding.sbSkipBtn.visibility = View.GONE
+
// set media sources for the player
setResolutionAndSubtitles()
prepareExoPlayerView()
diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml
index baf56d2b0..9b4ff02b8 100644
--- a/app/src/main/res/layout/fragment_player.xml
+++ b/app/src/main/res/layout/fragment_player.xml
@@ -378,8 +378,44 @@
android:layout_gravity="center"
android:gravity="center" />
-
+
+
+
+
+
+
+
+
+
+
+
+
Mobile data
Indicator for new videos
Show a badge with the amount of new videos if there are some.
+ Skip segment
+ Skip manually
+ Don\'t skip segments automatically, always prompt before.
diff --git a/app/src/main/res/xml/sponsorblock_settings.xml b/app/src/main/res/xml/sponsorblock_settings.xml
index 5a0f6a077..8e7291d2c 100644
--- a/app/src/main/res/xml/sponsorblock_settings.xml
+++ b/app/src/main/res/xml/sponsorblock_settings.xml
@@ -16,6 +16,12 @@
app:key="sb_notifications_key"
app:title="@string/sponsorblock_notifications" />
+
+