Deprecate ControlDispatcher in the UI

PiperOrigin-RevId: 385129211
This commit is contained in:
kimvde 2021-07-16 13:44:20 +01:00 committed by Ian Baker
parent 3830848888
commit 31c9875ec9
6 changed files with 38 additions and 15 deletions

View File

@ -100,6 +100,12 @@
available commands.
* Update `DefaultControlDispatcher` `getRewindIncrementMs` and
`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.
* Video:
* Fix `IncorrectContextUseViolation` strict mode warning on Android 11
([#8246](https://github.com/google/ExoPlayer/pull/8246)).

View File

@ -48,9 +48,11 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.ForwardingPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Events;
import com.google.android.exoplayer2.Player.State;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.RepeatModeUtil;
@ -599,10 +601,11 @@ public class PlayerControlView extends FrameLayout {
}
/**
* Sets the {@link com.google.android.exoplayer2.ControlDispatcher}.
*
* @param controlDispatcher The {@link com.google.android.exoplayer2.ControlDispatcher}.
* @deprecated Use a {@link ForwardingPlayer} and pass it to {@link #setPlayer(Player)} instead.
* You can also customize some operations when configuring the player (for example by using
* {@link SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
*/
@Deprecated
public void setControlDispatcher(ControlDispatcher controlDispatcher) {
if (this.controlDispatcher != controlDispatcher) {
this.controlDispatcher = controlDispatcher;

View File

@ -53,7 +53,9 @@ import androidx.media.app.NotificationCompat.MediaStyle;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.DefaultControlDispatcher;
import com.google.android.exoplayer2.ForwardingPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.util.NotificationUtil;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented;
@ -815,10 +817,13 @@ public class PlayerNotificationManager {
}
/**
* Sets the {@link ControlDispatcher}.
*
* @param controlDispatcher The {@link ControlDispatcher}.
* @deprecated Use a {@link ForwardingPlayer} and pass it to {@link #setPlayer(Player)} instead.
* You can also customize some operations when configuring the player (for example by using
* {@link SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}), or configure whether the
* rewind and fast forward actions should be used with {{@link #setUseRewindAction(boolean)}}
* and {@link #setUseFastForwardAction(boolean)}.
*/
@Deprecated
public final void setControlDispatcher(ControlDispatcher controlDispatcher) {
if (this.controlDispatcher != controlDispatcher) {
this.controlDispatcher = controlDispatcher;

View File

@ -48,9 +48,11 @@ import androidx.core.content.ContextCompat;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.Format;
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;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.metadata.Metadata;
@ -929,10 +931,11 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
}
/**
* Sets the {@link ControlDispatcher}.
*
* @param controlDispatcher The {@link ControlDispatcher}.
* @deprecated Use a {@link ForwardingPlayer} and pass it to {@link #setPlayer(Player)} instead.
* You can also customize some operations when configuring the player (for example by using
* {@link SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
*/
@Deprecated
public void setControlDispatcher(ControlDispatcher controlDispatcher) {
Assertions.checkStateNotNull(controller);
controller.setControlDispatcher(controlDispatcher);

View File

@ -61,9 +61,11 @@ import com.google.android.exoplayer2.DefaultControlDispatcher;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ForwardingPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Events;
import com.google.android.exoplayer2.Player.State;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
@ -832,10 +834,11 @@ public class StyledPlayerControlView extends FrameLayout {
}
/**
* Sets the {@link ControlDispatcher}.
*
* @param controlDispatcher The {@link ControlDispatcher}.
* @deprecated Use a {@link ForwardingPlayer} and pass it to {@link #setPlayer(Player)} instead.
* You can also customize some operations when configuring the player (for example by using
* {@link SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
*/
@Deprecated
public void setControlDispatcher(ControlDispatcher controlDispatcher) {
if (this.controlDispatcher != controlDispatcher) {
this.controlDispatcher = controlDispatcher;

View File

@ -49,9 +49,11 @@ import androidx.core.content.ContextCompat;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.Format;
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;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.metadata.Metadata;
@ -947,10 +949,11 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
}
/**
* Sets the {@link ControlDispatcher}.
*
* @param controlDispatcher The {@link ControlDispatcher}.
* @deprecated Use a {@link ForwardingPlayer} and pass it to {@link #setPlayer(Player)} instead.
* You can also customize some operations when configuring the player (for example by using
* {@link SimpleExoPlayer.Builder#setSeekBackIncrementMs(long)}).
*/
@Deprecated
public void setControlDispatcher(ControlDispatcher controlDispatcher) {
Assertions.checkStateNotNull(controller);
controller.setControlDispatcher(controlDispatcher);