From 038b8f7ff76ecd423dbcc0fda106703064a2da5e Mon Sep 17 00:00:00 2001 From: aayush262 <99584765+aayush2622@users.noreply.github.com> Date: Tue, 9 Jan 2024 20:12:19 +0530 Subject: [PATCH] better FastForward bar (#117) --- .../ani/dantotsu/media/anime/ExoplayerView.kt | 10 +++++++--- app/src/main/res/layout/exo_player_view.xml | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 8643d9deb09..f96408676d4 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -31,6 +31,7 @@ import android.view.* import android.view.KeyEvent.* import android.view.animation.AnimationUtils import android.widget.AdapterView +import android.widget.FrameLayout import android.widget.ImageButton import android.widget.Spinner import android.widget.TextView @@ -42,6 +43,7 @@ import androidx.core.content.res.ResourcesCompat import androidx.core.math.MathUtils.clamp import androidx.core.view.WindowCompat import androidx.core.view.updateLayoutParams +import androidx.core.view.updatePadding import androidx.lifecycle.lifecycleScope import androidx.media3.common.* import androidx.media3.common.C.AUDIO_CONTENT_TYPE_MOVIE @@ -103,6 +105,7 @@ import androidx.mediarouter.app.MediaRouteButton import ani.dantotsu.download.video.Helper import com.google.android.gms.cast.framework.CastButtonFactory import com.google.android.gms.cast.framework.CastContext +import com.google.android.material.snackbar.Snackbar @UnstableApi @SuppressLint("SetTextI18n", "ClickableViewAccessibility") @@ -832,18 +835,19 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL audioManager.setStreamVolume(STREAM_MUSIC, volume, 0) volumeHide() } - + val fastForward = playerView.findViewById(R.id.exo_fast_forward_text) fun fastForward() { isFastForwarding = true exoPlayer.setPlaybackSpeed(exoPlayer.playbackParameters.speed * 2) - snackString("Playing at ${exoPlayer.playbackParameters.speed}x speed") + fastForward.visibility = View.VISIBLE + fastForward.text = ("${exoPlayer.playbackParameters.speed}x") } fun stopFastForward() { if (isFastForwarding) { isFastForwarding = false exoPlayer.setPlaybackSpeed(exoPlayer.playbackParameters.speed / 2) - snackString("Playing at default speed: ${exoPlayer.playbackParameters.speed}x") + fastForward.visibility = View.GONE } } diff --git a/app/src/main/res/layout/exo_player_view.xml b/app/src/main/res/layout/exo_player_view.xml index d569ec3ae30..d9d64acb29a 100644 --- a/app/src/main/res/layout/exo_player_view.xml +++ b/app/src/main/res/layout/exo_player_view.xml @@ -163,6 +163,25 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> + +