Skip to content

Commit

Permalink
better FastForward bar (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 authored Jan 9, 2024
1 parent 3d3c9fe commit 038b8f7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -832,18 +835,19 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
audioManager.setStreamVolume(STREAM_MUSIC, volume, 0)
volumeHide()
}

val fastForward = playerView.findViewById<TextView>(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
}
}

Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/layout/exo_player_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,25 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<TextView
android:id="@+id/exo_fast_forward_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:layout_gravity="top|center"
android:fontFamily="@font/poppins_semi_bold"
android:paddingStart="9dp"
android:paddingEnd="9dp"
android:visibility="gone"
android:background="@drawable/rounded_top_nav"
android:textColor="@color/bg_white"
android:textSize="18sp"
tools:hint= "2x"
tools:visibility="visible"
app:drawableEndCompat="@drawable/ic_round_fast_forward_24"
app:drawableTint= "@color/bg_white"/>

<com.google.android.material.card.MaterialCardView
android:id="@+id/exo_skip_timestamp"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 038b8f7

Please sign in to comment.