mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
add flag to hide play/pause button
exoghi/4056 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193960004
This commit is contained in:
parent
f7c5e475a7
commit
301bb3ada4
1 changed files with 23 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
@ -485,6 +487,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};
|
||||
|
|
|
|||
Loading…
Reference in a new issue