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 {
private NotificationListener notificationListener;
private MediaSessionCompat.Token mediaSessionToken;
private boolean useNavigationActions;
private boolean usePlayPauseActions;
private @Nullable String stopAction;
private @Nullable PendingIntent stopPendingIntent;
private long fastForwardMs;
......@@ -381,6 +382,7 @@ public class PlayerNotificationManager {
setStopAction(ACTION_STOP);
useNavigationActions = true;
usePlayPauseActions = true;
ongoing = true;
colorized = true;
useChronometer = true;
......@@ -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
* null} is passed the stop action is not displayed.
*
......@@ -878,10 +892,12 @@ public class PlayerNotificationManager {
if (rewindMs > 0) {
stringActions.add(ACTION_REWIND);
}
if (player.getPlayWhenReady()) {
stringActions.add(ACTION_PAUSE);
} else if (!player.getPlayWhenReady()) {
stringActions.add(ACTION_PLAY);
if (usePlayPauseActions) {
if (player.getPlayWhenReady()) {
stringActions.add(ACTION_PAUSE);
} else {
stringActions.add(ACTION_PLAY);
}
}
if (fastForwardMs > 0) {
stringActions.add(ACTION_FAST_FORWARD);
......@@ -908,6 +924,9 @@ public class PlayerNotificationManager {
* @param player The player for which state to build a notification.
*/
protected int[] getActionIndicesForCompactView(Player player) {
if (!usePlayPauseActions) {
return new int[0];
}
int actionIndex = useNavigationActions ? 1 : 0;
actionIndex += fastForwardMs > 0 ? 1 : 0;
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