5

I'm looking for a way to set a skip interval for "forward" and "rewind" buttons. By default pressing forward skips 15 seconds of video, but pressing rewind skips only 5 seconds. I'd like to set both to 5 seconds but I can't find any API to do so.

Question: How to override skip-interval for "forward" and "rewind" buttons in ExoPlayer 2?

Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148

4 Answers4

12

It should be app:fastforward_increment="5000" and app:rewind_increment="5000"

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
                    android:id="@+id/item_comment_exo_player_view"
                    android:layout_width="match_parent"
                    android:layout_height="250dp"
                    android:layout_gravity="center"
                    android:background="@color/black"
                    android:fitsSystemWindows="true"
                    android:paddingBottom="0dp"
                    android:paddingEnd="0dp"
                    android:paddingStart="0dp"
                    android:paddingTop="0dp"
                    app:controller_layout_id="@layout/custom_playback_control"
                    app:fastforward_increment="5000"
                    app:rewind_increment="5000"
                    app:show_timeout="2000" />
Phong Nguyen
  • 6,897
  • 2
  • 26
  • 36
  • 4
    Thank you. Adding it to `SimpleExoPlayerView ` didn't help, but once I added it to `PlayerControlView` it worked. – Sasha Shpota Sep 24 '18 at 11:35
1

I tried the XML attributes specified but still face the same issue i.e. pressing forward skips 15 seconds of video, but pressing rewind skips only 5 seconds.

so I override the values of the attributes in Java code to set both to skip 5 seconds only.

// This will override the player controller XML attributes.
    playerView.setFastForwardIncrementMs(5000);
    playerView.setRewindIncrementMs(5000);

For more references check official doc.

Harpreet
  • 2,990
  • 3
  • 38
  • 52
0

app:fastforward_increment="5000" and app:rewind_increment="5000" is now Deprecated code instead of use this to implement rewind and forward feature.

Just add this code on your button onclick listener.

//switch case onClick listener for 'Forward' and 'Rewind'

    case R.id.exo_rewind:
            int rewind = (int) player.getCurrentPosition();
            rewind = rewind - 10000; // 10000 = 10 Seconds
            player.seekTo(rewind);
        break;

    case R.id.exo_forward:
            int forward = (int) player.getCurrentPosition();
            forward = forward + 10000; // 10000 = 10 Seconds
            player.seekTo(forward);
        break;
0

setFastForwardIncrementMs (or app:fastforward_increment) and setRewindIncrementMs (or app:rewind_increment) don't exist anymore.

In Media3 ExoPlayer you can set the interval while building the player:

Player player = new ExoPlayer.Builder(context)
        .setSeekForwardIncrementMs(10000L)
        .setSeekBackIncrementMs(10000L)
        .build();
nhcodes
  • 1,206
  • 8
  • 20