Deprecate ControlDispatcher in Leanback library

PiperOrigin-RevId: 385503851
This commit is contained in:
kimvde 2021-07-19 09:45:33 +01:00 committed by Ian Baker
parent fdc2cbd7e2
commit 30e65acf63
2 changed files with 12 additions and 10 deletions

View File

@ -102,10 +102,7 @@
`getFastForwardIncrementMs` to take the player as parameter. `getFastForwardIncrementMs` to take the player as parameter.
* Deprecate `setControlDispatcher` in `PlayerView`, `StyledPlayerView`, * Deprecate `setControlDispatcher` in `PlayerView`, `StyledPlayerView`,
`PlayerControlView`, `StyledPlayerControlView` and `PlayerControlView`, `StyledPlayerControlView` and
`PlayerNotificationManager`. Instead, you can use a `ForwardingPlayer`, `PlayerNotificationManager`.
configure the player as needed (whenever possible) or, for
`PlayerNotificationManager`, use `setUseRewindAction` and
`setUseFastForwardAction` to configure whether to use these actions.
* Video: * Video:
* Fix `IncorrectContextUseViolation` strict mode warning on Android 11 * Fix `IncorrectContextUseViolation` strict mode warning on Android 11
([#8246](https://github.com/google/ExoPlayer/pull/8246)). ([#8246](https://github.com/google/ExoPlayer/pull/8246)).
@ -171,6 +168,8 @@
* Cronet extension: * Cronet extension:
* Add `CronetDataSource.Factory.setRequestPriority` to allow setting the * Add `CronetDataSource.Factory.setRequestPriority` to allow setting the
priority of requests made by `CronetDataSource` instances. priority of requests made by `CronetDataSource` instances.
* Leanback:
* Deprecate `setControlDispatcher` in `LeanbackPlayerAdapter`.
### 2.14.1 (2021-06-11) ### 2.14.1 (2021-06-11)

View File

@ -29,6 +29,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher; import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.DefaultControlDispatcher; import com.google.android.exoplayer2.DefaultControlDispatcher;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.ForwardingPlayer;
import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.DiscontinuityReason; import com.google.android.exoplayer2.Player.DiscontinuityReason;
@ -76,11 +77,11 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
} }
/** /**
* Sets the {@link ControlDispatcher}. * @deprecated Use a {@link ForwardingPlayer} and pass it to the constructor instead. You can also
* * customize some operations when configuring the player (for example by using {@code
* @param controlDispatcher The {@link ControlDispatcher}, or null to use {@link * SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
* DefaultControlDispatcher}.
*/ */
@Deprecated
public void setControlDispatcher(@Nullable ControlDispatcher controlDispatcher) { public void setControlDispatcher(@Nullable ControlDispatcher controlDispatcher) {
this.controlDispatcher = this.controlDispatcher =
controlDispatcher == null ? new DefaultControlDispatcher() : controlDispatcher; controlDispatcher == null ? new DefaultControlDispatcher() : controlDispatcher;
@ -158,14 +159,16 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
} else if (player.getPlaybackState() == Player.STATE_ENDED) { } else if (player.getPlaybackState() == Player.STATE_ENDED) {
controlDispatcher.dispatchSeekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET); controlDispatcher.dispatchSeekTo(player, player.getCurrentWindowIndex(), C.TIME_UNSET);
} }
if (controlDispatcher.dispatchSetPlayWhenReady(player, true)) { if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)
&& controlDispatcher.dispatchSetPlayWhenReady(player, true)) {
getCallback().onPlayStateChanged(this); getCallback().onPlayStateChanged(this);
} }
} }
@Override @Override
public void pause() { public void pause() {
if (controlDispatcher.dispatchSetPlayWhenReady(player, false)) { if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)
&& controlDispatcher.dispatchSetPlayWhenReady(player, false)) {
getCallback().onPlayStateChanged(this); getCallback().onPlayStateChanged(this);
} }
} }