diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ddfef6b174..a5a3173a8b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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)). diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java index 14b22bba34..dd8a6d212f 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java @@ -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; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java index e030efe184..53d989d9d6 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java @@ -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; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index 4241816db2..0009262c45 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -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); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 077f228dbb..8a4b6ae9a9 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -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; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index 0d4826daf0..3b7bf437f4 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -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);