mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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 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 {
|
||||||
setStopAction(ACTION_STOP);
|
setStopAction(ACTION_STOP);
|
||||||
|
|
||||||
useNavigationActions = true;
|
useNavigationActions = true;
|
||||||
|
usePlayPauseActions = true;
|
||||||
ongoing = true;
|
ongoing = true;
|
||||||
colorized = true;
|
colorized = true;
|
||||||
useChronometer = 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
|
* 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,10 +892,12 @@ public class PlayerNotificationManager {
|
||||||
if (rewindMs > 0) {
|
if (rewindMs > 0) {
|
||||||
stringActions.add(ACTION_REWIND);
|
stringActions.add(ACTION_REWIND);
|
||||||
}
|
}
|
||||||
if (player.getPlayWhenReady()) {
|
if (usePlayPauseActions) {
|
||||||
stringActions.add(ACTION_PAUSE);
|
if (player.getPlayWhenReady()) {
|
||||||
} else if (!player.getPlayWhenReady()) {
|
stringActions.add(ACTION_PAUSE);
|
||||||
stringActions.add(ACTION_PLAY);
|
} else {
|
||||||
|
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 {
|
||||||
* @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};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue