diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 5554041b59..5a6afe1b58 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -66,6 +66,9 @@ * PlayerNotificationManager: * Add `PendingIntent.FLAG_IMMUTABLE` flag to BroadcastReceiver to support Android 12. + * Add `setUseFastForwardActionInCompactView(boolean)` and + `setUseRewindActionInCompactView(boolean)` to make it possible to show + seek actions in compact view mode. * DRM: * Don't restore offline keys before releasing them. In OEMCrypto v16+ keys must be released without restoring them first. 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 2c17a39ef7..dd84cc9d89 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 @@ -91,12 +91,24 @@ import java.util.Map; *
If set to {@code true}, {@link #setUseFastForwardActionInCompactView(boolean) + * setUseFastForwardActionInCompactView} is set to false. + * * @param useNextActionInCompactView Whether to use the next action in compact view. */ public void setUseNextActionInCompactView(boolean useNextActionInCompactView) { if (this.useNextActionInCompactView != useNextActionInCompactView) { this.useNextActionInCompactView = useNextActionInCompactView; + if (useNextActionInCompactView) { + useFastForwardActionInCompactView = false; + } invalidate(); } } @@ -822,11 +842,56 @@ public class PlayerNotificationManager { * action should also be used in compact view. Has no effect if {@link #setUsePreviousAction * usePreviousAction} is {@code false}. * + *
If set to {@code true}, {@link #setUseRewindActionInCompactView(boolean) + * setUseRewindActionInCompactView} is set to false. + * * @param usePreviousActionInCompactView Whether to use the previous action in compact view. */ public void setUsePreviousActionInCompactView(boolean usePreviousActionInCompactView) { if (this.usePreviousActionInCompactView != usePreviousActionInCompactView) { this.usePreviousActionInCompactView = usePreviousActionInCompactView; + if (usePreviousActionInCompactView) { + useRewindActionInCompactView = false; + } + invalidate(); + } + } + + /** + * Sets whether the fast forward action should also be used in compact view. Has no effect if + * {@link #ACTION_FAST_FORWARD} is not enabled, for instance if the media is not seekable. + * + *
If set to {@code true}, {@link #setUseNextActionInCompactView(boolean) + * setUseNextActionInCompactView} is set to false. + * + * @param useFastForwardActionInCompactView Whether to use the fast forward action in compact + * view. + */ + public void setUseFastForwardActionInCompactView(boolean useFastForwardActionInCompactView) { + if (this.useFastForwardActionInCompactView != useFastForwardActionInCompactView) { + this.useFastForwardActionInCompactView = useFastForwardActionInCompactView; + if (useFastForwardActionInCompactView) { + useNextActionInCompactView = false; + } + invalidate(); + } + } + + /** + * Sets whether the rewind action should also be used in compact view. Has no effect if {@link + * #ACTION_REWIND} is not enabled, for instance if the media is not seekable. + * + *
If set to {@code true}, {@link #setUsePreviousActionInCompactView(boolean)
+ * setUsePreviousActionInCompactView} is set to false.
+ *
+ * @param useRewindActionInCompactView Whether to use the rewind action in compact view.
+ */
+ public void setUseRewindActionInCompactView(boolean useRewindActionInCompactView) {
+ if (this.useRewindActionInCompactView != useRewindActionInCompactView) {
+ this.useRewindActionInCompactView = useRewindActionInCompactView;
+ if (useRewindActionInCompactView) {
+ usePreviousActionInCompactView = false;
+ }
invalidate();
}
}
@@ -1255,14 +1320,19 @@ public class PlayerNotificationManager {
protected int[] getActionIndicesForCompactView(List