Commit 301bb3ad by bachinger Committed by Oliver Woodman

add flag to hide play/pause button

exoghi/4056

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193960004
parent f7c5e475
...@@ -276,6 +276,7 @@ public class PlayerNotificationManager { ...@@ -276,6 +276,7 @@ public class PlayerNotificationManager {
private NotificationListener notificationListener; private NotificationListener notificationListener;
private MediaSessionCompat.Token mediaSessionToken; private MediaSessionCompat.Token mediaSessionToken;
private boolean useNavigationActions; private boolean useNavigationActions;
private boolean usePlayPauseActions;
private @Nullable String stopAction; private @Nullable String stopAction;
private @Nullable PendingIntent stopPendingIntent; private @Nullable PendingIntent stopPendingIntent;
private long fastForwardMs; private long fastForwardMs;
...@@ -381,6 +382,7 @@ public class PlayerNotificationManager { ...@@ -381,6 +382,7 @@ public class PlayerNotificationManager {
setStopAction(ACTION_STOP); setStopAction(ACTION_STOP);
useNavigationActions = true; useNavigationActions = true;
usePlayPauseActions = true;
ongoing = true; ongoing = true;
colorized = true; colorized = true;
useChronometer = true; useChronometer = true;
...@@ -486,6 +488,18 @@ public class PlayerNotificationManager { ...@@ -486,6 +488,18 @@ public class PlayerNotificationManager {
} }
/** /**
* Sets whether the play and pause actions should be used.
*
* @param usePlayPauseActions Whether to use play and pause actions.
*/
public final void setUsePlayPauseActions(boolean usePlayPauseActions) {
if (this.usePlayPauseActions != usePlayPauseActions) {
this.usePlayPauseActions = usePlayPauseActions;
maybeUpdateNotification();
}
}
/**
* Sets the name of the action to be used as stop action to cancel the notification. If {@code * Sets the name of the action to be used as stop action to cancel the notification. If {@code
* null} is passed the stop action is not displayed. * null} is passed the stop action is not displayed.
* *
...@@ -878,11 +892,13 @@ public class PlayerNotificationManager { ...@@ -878,11 +892,13 @@ public class PlayerNotificationManager {
if (rewindMs > 0) { if (rewindMs > 0) {
stringActions.add(ACTION_REWIND); stringActions.add(ACTION_REWIND);
} }
if (usePlayPauseActions) {
if (player.getPlayWhenReady()) { if (player.getPlayWhenReady()) {
stringActions.add(ACTION_PAUSE); stringActions.add(ACTION_PAUSE);
} else if (!player.getPlayWhenReady()) { } else {
stringActions.add(ACTION_PLAY); stringActions.add(ACTION_PLAY);
} }
}
if (fastForwardMs > 0) { if (fastForwardMs > 0) {
stringActions.add(ACTION_FAST_FORWARD); stringActions.add(ACTION_FAST_FORWARD);
} }
...@@ -908,6 +924,9 @@ public class PlayerNotificationManager { ...@@ -908,6 +924,9 @@ public class PlayerNotificationManager {
* @param player The player for which state to build a notification. * @param player The player for which state to build a notification.
*/ */
protected int[] getActionIndicesForCompactView(Player player) { protected int[] getActionIndicesForCompactView(Player player) {
if (!usePlayPauseActions) {
return new int[0];
}
int actionIndex = useNavigationActions ? 1 : 0; int actionIndex = useNavigationActions ? 1 : 0;
actionIndex += fastForwardMs > 0 ? 1 : 0; actionIndex += fastForwardMs > 0 ? 1 : 0;
return new int[] {actionIndex}; return new int[] {actionIndex};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment