diff --git a/app/src/main/java/com/github/libretube/extensions/SeekBy.kt b/app/src/main/java/com/github/libretube/extensions/SeekBy.kt
new file mode 100644
index 000000000..86f5c138a
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/extensions/SeekBy.kt
@@ -0,0 +1,10 @@
+package com.github.libretube.extensions
+
+import androidx.media3.common.Player
+
+/**
+ * Forward or rewind by the provided [timeDiff] in milliseconds
+ */
+fun Player.seekBy(timeDiff: Long) {
+ seekTo(currentPosition + timeDiff)
+}
diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt
index f1041e7fe..a5a811d5b 100644
--- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt
@@ -26,6 +26,7 @@ import com.github.libretube.constants.IntentData
import com.github.libretube.databinding.FragmentAudioPlayerBinding
import com.github.libretube.enums.ShareObjectType
import com.github.libretube.extensions.normalize
+import com.github.libretube.extensions.seekBy
import com.github.libretube.extensions.toID
import com.github.libretube.helpers.AudioHelper
import com.github.libretube.helpers.BackgroundHelper
@@ -129,6 +130,16 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
PlayingQueue.onQueueItemSelected(currentIndex + 1)
}
+ listOf(binding.forwardTV, binding.rewindTV).forEach {
+ it.text = (PlayerHelper.seekIncrement / 1000).toString()
+ }
+ binding.rewindFL.setOnClickListener {
+ playerService?.player?.seekBy(-PlayerHelper.seekIncrement)
+ }
+ binding.forwardFL.setOnClickListener {
+ playerService?.player?.seekBy(PlayerHelper.seekIncrement)
+ }
+
binding.openQueue.setOnClickListener {
PlayingQueueSheet().show(childFragmentManager)
}
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 98a36f638..b6887e598 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
@@ -73,6 +73,7 @@ import com.github.libretube.enums.ShareObjectType
import com.github.libretube.extensions.formatShort
import com.github.libretube.extensions.hideKeyboard
import com.github.libretube.extensions.parcelable
+import com.github.libretube.extensions.seekBy
import com.github.libretube.extensions.setMetadata
import com.github.libretube.extensions.toID
import com.github.libretube.extensions.toastFromMainDispatcher
@@ -214,11 +215,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
PlayerEvent.Forward -> {
- exoPlayer.seekTo(exoPlayer.currentPosition + PlayerHelper.seekIncrement)
+ exoPlayer.seekBy(PlayerHelper.seekIncrement)
}
PlayerEvent.Rewind -> {
- exoPlayer.seekTo(exoPlayer.currentPosition - PlayerHelper.seekIncrement)
+ exoPlayer.seekBy(-PlayerHelper.seekIncrement)
}
PlayerEvent.Next -> {
diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt
index f663141be..37b06c7b0 100644
--- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt
+++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt
@@ -40,6 +40,7 @@ import com.github.libretube.databinding.PlayerGestureControlsViewBinding
import com.github.libretube.extensions.dpToPx
import com.github.libretube.extensions.normalize
import com.github.libretube.extensions.round
+import com.github.libretube.extensions.seekBy
import com.github.libretube.helpers.AudioHelper
import com.github.libretube.helpers.BrightnessHelper
import com.github.libretube.helpers.PlayerHelper
@@ -267,10 +268,10 @@ open class CustomExoPlayerView(
it?.text = seekIncrementText
}
binding.forwardBTN.setOnClickListener {
- player?.seekTo(player!!.currentPosition + PlayerHelper.seekIncrement)
+ player?.seekBy(PlayerHelper.seekIncrement)
}
binding.rewindBTN.setOnClickListener {
- player?.seekTo(player!!.currentPosition - PlayerHelper.seekIncrement)
+ player?.seekBy(-PlayerHelper.seekIncrement)
}
if (PlayerHelper.doubleTapToSeek) return
@@ -363,7 +364,7 @@ open class CustomExoPlayerView(
}
private fun rewind() {
- player?.seekTo((player?.currentPosition ?: 0L) - PlayerHelper.seekIncrement)
+ player?.seekBy(-PlayerHelper.seekIncrement)
// show the rewind button
doubleTapOverlayBinding?.apply {
@@ -378,7 +379,7 @@ open class CustomExoPlayerView(
}
private fun forward() {
- player?.seekTo(player!!.currentPosition + PlayerHelper.seekIncrement)
+ player?.seekBy(PlayerHelper.seekIncrement)
// show the forward button
doubleTapOverlayBinding?.apply {
diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt
index 9388a824f..4ea980d63 100644
--- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt
+++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt
@@ -30,6 +30,7 @@ import com.github.libretube.R
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
+import com.github.libretube.extensions.seekBy
import com.github.libretube.helpers.BackgroundHelper
import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.PlayerHelper
@@ -251,11 +252,11 @@ class NowPlayingNotification(
}
REWIND -> {
- player.seekTo(player.currentPosition - PlayerHelper.seekIncrement)
+ player.seekBy(-PlayerHelper.seekIncrement)
}
FORWARD -> {
- player.seekTo(player.currentPosition + PlayerHelper.seekIncrement)
+ player.seekBy(PlayerHelper.seekIncrement)
}
PLAY_PAUSE -> {
diff --git a/app/src/main/res/layout/fragment_audio_player.xml b/app/src/main/res/layout/fragment_audio_player.xml
index d94474069..977467216 100644
--- a/app/src/main/res/layout/fragment_audio_player.xml
+++ b/app/src/main/res/layout/fragment_audio_player.xml
@@ -186,6 +186,31 @@
android:layout_marginTop="10dp"
android:layout_marginBottom="36dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:visibility="gone" />