Remove fastforward_increment and rewind_increment attributes

This values won't be configurable from the UI anymore once the
DefaultControlDispatcher is removed.

They can be configured in the Player or by using a ForwardingPlayer.

PiperOrigin-RevId: 385113498
This commit is contained in:
kimvde 2021-07-16 11:34:59 +01:00 committed by Ian Baker
parent 227f9a3b93
commit 626c3e9843
4 changed files with 18 additions and 55 deletions

View file

@ -90,6 +90,14 @@
ensures programmatic changes to the `SubtitleView` will propagate down.
* Add `setUseRewindAction` and `setUseFastForwardAction` to
`PlayerNotificationManager`.
* Remove `rewind_increment` and `fastforward_increment` attributes from
`PlayerControlView` and `StyledPlayerControlView`. These increments can
be customized by configuring the `Player` (whenever possible) or by
using a `ForwardingPlayer` that overrides `getSeekBackIncrement`,
`seekBack`, `getSeekForwardIncrement` and `seekForward`. The
corresponding buttons can be disabled by using a `ForwardingPlayer`
that removes `COMMAND_SEEK_BACK` and `COMMAND_SEEK_FORWARD` from the
available commands.
* Video:
* Fix `IncorrectContextUseViolation` strict mode warning on Android 11
([#8246](https://github.com/google/ExoPlayer/pull/8246)).

View file

@ -47,7 +47,6 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.DefaultControlDispatcher;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Events;
@ -100,17 +99,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
* <li>Corresponding method: {@link #setShowNextButton(boolean)}
* <li>Default: true
* </ul>
* <li><b>{@code rewind_increment}</b> - The duration of the rewind applied when the user taps the
* rewind button, in milliseconds. Use zero to disable the rewind button.
* <ul>
* <li>Corresponding method: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_REWIND_MS}
* </ul>
* <li><b>{@code fastforward_increment}</b> - Like {@code rewind_increment}, but for fast forward.
* <ul>
* <li>Corresponding method: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_FAST_FORWARD_MS}
* </ul>
* <li><b>{@code repeat_toggle_modes}</b> - A flagged enumeration value specifying which repeat
* mode toggle options are enabled. Valid values are: {@code none}, {@code one}, {@code all},
* or {@code one|all}.
@ -383,17 +371,12 @@ public class PlayerControlView extends FrameLayout {
showPreviousButton = true;
showNextButton = true;
showShuffleButton = false;
int rewindMs = DefaultControlDispatcher.DEFAULT_REWIND_MS;
int fastForwardMs = DefaultControlDispatcher.DEFAULT_FAST_FORWARD_MS;
if (playbackAttrs != null) {
TypedArray a =
context
.getTheme()
.obtainStyledAttributes(playbackAttrs, R.styleable.PlayerControlView, 0, 0);
try {
rewindMs = a.getInt(R.styleable.PlayerControlView_rewind_increment, rewindMs);
fastForwardMs =
a.getInt(R.styleable.PlayerControlView_fastforward_increment, fastForwardMs);
showTimeoutMs = a.getInt(R.styleable.PlayerControlView_show_timeout, showTimeoutMs);
controllerLayoutId =
a.getResourceId(R.styleable.PlayerControlView_controller_layout_id, controllerLayoutId);
@ -427,8 +410,7 @@ public class PlayerControlView extends FrameLayout {
extraAdGroupTimesMs = new long[0];
extraPlayedAdGroups = new boolean[0];
componentListener = new ComponentListener();
controlDispatcher =
new com.google.android.exoplayer2.DefaultControlDispatcher(fastForwardMs, rewindMs);
controlDispatcher = new com.google.android.exoplayer2.DefaultControlDispatcher();
updateProgressAction = this::updateProgress;
hideAction = this::hide;

View file

@ -122,17 +122,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
* <li>Corresponding method: {@link #setShowNextButton(boolean)}
* <li>Default: true
* </ul>
* <li><b>{@code rewind_increment}</b> - The duration of the rewind applied when the user taps the
* rewind button, in milliseconds. Use zero to disable the rewind button.
* <ul>
* <li>Corresponding method: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_REWIND_MS}
* </ul>
* <li><b>{@code fastforward_increment}</b> - Like {@code rewind_increment}, but for fast forward.
* <ul>
* <li>Corresponding method: {@link #setControlDispatcher(ControlDispatcher)}
* <li>Default: {@link DefaultControlDispatcher#DEFAULT_FAST_FORWARD_MS}
* </ul>
* <li><b>{@code repeat_toggle_modes}</b> - A flagged enumeration value specifying which repeat
* mode toggle options are enabled. Valid values are: {@code none}, {@code one}, {@code all},
* or {@code one|all}.
@ -433,8 +422,6 @@ public class StyledPlayerControlView extends FrameLayout {
private long[] extraAdGroupTimesMs;
private boolean[] extraPlayedAdGroups;
private long currentWindowOffset;
private long rewindMs;
private long fastForwardMs;
private StyledPlayerControlViewLayoutManager controlViewLayoutManager;
private Resources resources;
@ -484,8 +471,6 @@ public class StyledPlayerControlView extends FrameLayout {
@Nullable AttributeSet playbackAttrs) {
super(context, attrs, defStyleAttr);
int controllerLayoutId = R.layout.exo_styled_player_control_view;
rewindMs = DefaultControlDispatcher.DEFAULT_REWIND_MS;
fastForwardMs = DefaultControlDispatcher.DEFAULT_FAST_FORWARD_MS;
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES;
timeBarMinUpdateIntervalMs = DEFAULT_TIME_BAR_MIN_UPDATE_INTERVAL_MS;
@ -504,10 +489,6 @@ public class StyledPlayerControlView extends FrameLayout {
.getTheme()
.obtainStyledAttributes(playbackAttrs, R.styleable.StyledPlayerControlView, 0, 0);
try {
rewindMs = a.getInt(R.styleable.StyledPlayerControlView_rewind_increment, (int) rewindMs);
fastForwardMs =
a.getInt(
R.styleable.StyledPlayerControlView_fastforward_increment, (int) fastForwardMs);
controllerLayoutId =
a.getResourceId(
R.styleable.StyledPlayerControlView_controller_layout_id, controllerLayoutId);
@ -555,7 +536,7 @@ public class StyledPlayerControlView extends FrameLayout {
playedAdGroups = new boolean[0];
extraAdGroupTimesMs = new long[0];
extraPlayedAdGroups = new boolean[0];
controlDispatcher = new DefaultControlDispatcher(fastForwardMs, rewindMs);
controlDispatcher = new DefaultControlDispatcher();
updateProgressAction = this::updateProgress;
durationView = findViewById(R.id.exo_duration);
@ -1160,9 +1141,10 @@ public class StyledPlayerControlView extends FrameLayout {
}
private void updateRewindButton() {
if (controlDispatcher instanceof DefaultControlDispatcher) {
rewindMs = ((DefaultControlDispatcher) controlDispatcher).getRewindIncrementMs();
}
long rewindMs =
controlDispatcher instanceof DefaultControlDispatcher
? ((DefaultControlDispatcher) controlDispatcher).getRewindIncrementMs()
: C.DEFAULT_SEEK_BACK_INCREMENT_MS;
int rewindSec = (int) (rewindMs / 1_000);
if (rewindButtonTextView != null) {
rewindButtonTextView.setText(String.valueOf(rewindSec));
@ -1175,9 +1157,10 @@ public class StyledPlayerControlView extends FrameLayout {
}
private void updateFastForwardButton() {
if (controlDispatcher instanceof DefaultControlDispatcher) {
fastForwardMs = ((DefaultControlDispatcher) controlDispatcher).getFastForwardIncrementMs();
}
long fastForwardMs =
controlDispatcher instanceof DefaultControlDispatcher
? ((DefaultControlDispatcher) controlDispatcher).getFastForwardIncrementMs()
: C.DEFAULT_SEEK_FORWARD_INCREMENT_MS;
int fastForwardSec = (int) (fastForwardMs / 1_000);
if (fastForwardButtonTextView != null) {
fastForwardButtonTextView.setText(String.valueOf(fastForwardSec));

View file

@ -58,8 +58,6 @@
<!-- PlayerControlView and StyledPlayerControlView attributes -->
<attr name="show_timeout" format="integer"/>
<attr name="rewind_increment" format="integer"/>
<attr name="fastforward_increment" format="integer"/>
<attr name="show_rewind_button" format="boolean"/>
<attr name="show_fastforward_button" format="boolean"/>
<attr name="show_previous_button" format="boolean"/>
@ -109,8 +107,6 @@
<attr name="resize_mode"/>
<!-- PlayerControlView attributes -->
<attr name="show_timeout"/>
<attr name="rewind_increment"/>
<attr name="fastforward_increment"/>
<attr name="repeat_toggle_modes"/>
<attr name="show_shuffle_button"/>
<attr name="time_bar_min_update_interval"/>
@ -147,8 +143,6 @@
<attr name="resize_mode"/>
<!-- PlayerControlView attributes -->
<attr name="show_timeout"/>
<attr name="rewind_increment"/>
<attr name="fastforward_increment"/>
<attr name="repeat_toggle_modes"/>
<attr name="show_shuffle_button"/>
<attr name="show_subtitle_button"/>
@ -179,8 +173,6 @@
<declare-styleable name="PlayerControlView">
<attr name="show_timeout"/>
<attr name="rewind_increment"/>
<attr name="fastforward_increment"/>
<attr name="repeat_toggle_modes"/>
<attr name="show_rewind_button"/>
<attr name="show_fastforward_button"/>
@ -208,8 +200,6 @@
<declare-styleable name="StyledPlayerControlView">
<attr name="show_timeout"/>
<attr name="rewind_increment"/>
<attr name="fastforward_increment"/>
<attr name="repeat_toggle_modes"/>
<attr name="show_rewind_button"/>
<attr name="show_fastforward_button"/>