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.
* Deprecate `setControlDispatcher` in `PlayerView`, `StyledPlayerView`,
`PlayerControlView`, `StyledPlayerControlView` and
`PlayerNotificationManager`. Instead, you can use a `ForwardingPlayer`,
configure the player as needed (whenever possible) or, for
`PlayerNotificationManager`, use `setUseRewindAction` and
`setUseFastForwardAction` to configure whether to use these actions.
`PlayerNotificationManager`.
* Video:
* Fix `IncorrectContextUseViolation` strict mode warning on Android 11
([#8246](https://github.com/google/ExoPlayer/pull/8246)).
@ -171,6 +168,8 @@
* Cronet extension:
* Add `CronetDataSource.Factory.setRequestPriority` to allow setting the
priority of requests made by `CronetDataSource` instances.
* Leanback:
* Deprecate `setControlDispatcher` in `LeanbackPlayerAdapter`.
### 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.DefaultControlDispatcher;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.ForwardingPlayer;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.DiscontinuityReason;
@ -76,11 +77,11 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
}
/**
* Sets the {@link ControlDispatcher}.
*
* @param controlDispatcher The {@link ControlDispatcher}, or null to use {@link
* DefaultControlDispatcher}.
* @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
* SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
*/
@Deprecated
public void setControlDispatcher(@Nullable ControlDispatcher controlDispatcher) {
this.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) {
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);
}
}
@Override
public void pause() {
if (controlDispatcher.dispatchSetPlayWhenReady(player, false)) {
if (player.isCommandAvailable(Player.COMMAND_PLAY_PAUSE)
&& controlDispatcher.dispatchSetPlayWhenReady(player, false)) {
getCallback().onPlayStateChanged(this);
}
}