# PlayerNotificationManager

Artifact: [androidx.media3:media3-ui](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/ui/PlayerNotificationManager.java+class:androidx.media3.ui.PlayerNotificationManager)

*** ** * ** ***


```
@UnstableApi
public class PlayerNotificationManager
```

<br />

*** ** * ** ***

Starts, updates and cancels a media style notification reflecting the player state. The actions included in the notification can be customized along with their drawables, as described below.

The notification is cancelled when `null` is passed to `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setPlayer(androidx.media3.common.Player)` or when the notification is dismissed by the user.

If the player is released it must be removed from the manager by calling `
setPlayer(null)`.

## Action customization

Playback actions can be included or omitted as follows:

- **`usePlayPauseActions`** - Sets whether the play and pause actions are used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePlayPauseActions(boolean)`
  - Default: `true`
- **`useRewindAction`** - Sets whether the rewind action is used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseRewindAction(boolean)`
  - Default: `true`
- **`useRewindActionInCompactView`** - If `useRewindAction` is `true`, sets whether the rewind action is also used in compact view (including the lock screen notification). Else does nothing.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseRewindActionInCompactView(boolean)`
  - Default: `false`
- **`useFastForwardAction`** - Sets whether the fast forward action is used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardAction(boolean)`
  - Default: `true`
- **`useFastForwardActionInCompactView`** - If `useFastForwardAction` is `true`, sets whether the fast forward action is also used in compact view (including the lock screen notification). Else does nothing.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardActionInCompactView(boolean)`
  - Default: `false`
- **`usePreviousAction`** - Whether the previous action is used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)`
  - Default: `true`
- **`usePreviousActionInCompactView`** - If `usePreviousAction` is `
  true`, sets whether the previous action is also used in compact view (including the lock screen notification). Else does nothing.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousActionInCompactView(boolean)`
  - Default: `false`
- **`useNextAction`** - Whether the next action is used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)`
  - Default: `true`
- **`useNextActionInCompactView`** - If `useNextAction` is `true`, sets whether the next action is also used in compact view (including the lock screen notification). Else does nothing.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextActionInCompactView(boolean)`
  - Default: `false`
- **`useStopAction`** - Sets whether the stop action is used.
  - Corresponding setter: `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseStopAction(boolean)`
  - Default: `false`

## Overriding drawables

The drawables used by PlayerNotificationManager can be overridden by drawables with the same names defined in your application. The drawables that can be overridden are:

- **`exo_notification_small_icon`** - The icon passed by default to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setSmallIcon(int)`. A different icon can also be specified programmatically by calling `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setSmallIcon(int)`.
- **`exo_notification_play`** - The play icon.
- **`exo_notification_pause`** - The pause icon.
- **`exo_notification_rewind`** - The rewind icon.
- **`exo_notification_fastforward`** - The fast forward icon.
- **`exo_notification_previous`** - The previous icon.
- **`exo_notification_next`** - The next icon.
- **`exo_notification_stop`** - The stop icon.

Alternatively, the action icons can be set programmatically by using the `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Builder`.

Unlike the drawables above, the large icon (i.e. the icon passed to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setLargeIcon(android.graphics.Bitmap)` cannot be overridden in this way. Instead, the large icon is obtained from the `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter` passed to `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Builder#Builder(android.content.Context,int,java.lang.String,androidx.media3.ui.PlayerNotificationManager.MediaDescriptionAdapter)`.

Note: This class would require `https://developer.android.com/reference/android/Manifest.permission.html#POST_NOTIFICATIONS` permission if used without a `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setMediaSessionToken(android.media.session.MediaSession.Token)`.

## Summary

| ### Nested types |
|---|
| `public final inner class https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.BitmapCallback` Receives a `https://developer.android.com/reference/android/graphics/Bitmap.html`. |
| `public class https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Builder` A builder for `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager` instances. |
| `public interface https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver` Defines and handles custom actions. |
| `public interface https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter` An adapter to provide content assets of the media currently playing. |
| `public interface https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.NotificationListener` A listener for changes to the notification. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = [https://developer.android.com/reference/androidx/core/app/NotificationCompat.PRIORITY_DEFAULT, https://developer.android.com/reference/androidx/core/app/NotificationCompat.PRIORITY_MAX, https://developer.android.com/reference/androidx/core/app/NotificationCompat.PRIORITY_HIGH, https://developer.android.com/reference/androidx/core/app/NotificationCompat.PRIORITY_LOW, https://developer.android.com/reference/androidx/core/app/NotificationCompat.PRIORITY_MIN]) public annotation https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Priority` Priority of the notification (required for API 25 and lower). |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = [https://developer.android.com/reference/androidx/core/app/NotificationCompat.VISIBILITY_PRIVATE, https://developer.android.com/reference/androidx/core/app/NotificationCompat.VISIBILITY_PUBLIC, https://developer.android.com/reference/androidx/core/app/NotificationCompat.VISIBILITY_SECRET]) public annotation https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Visibility` Visibility of notification on the lock screen. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_FAST_FORWARD() = "androidx.media3.ui.notification.ffwd"` The action which fast forwards. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_NEXT() = "androidx.media3.ui.notification.next"` The action which skips to the next media item. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PAUSE() = "androidx.media3.ui.notification.pause"` The action which pauses playback. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PLAY() = "androidx.media3.ui.notification.play"` The action which starts playback. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PREVIOUS() = "androidx.media3.ui.notification.prev"` The action which skips to the previous media item. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_REWIND() = "androidx.media3.ui.notification.rewind"` The action which rewinds. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_STOP() = "androidx.media3.ui.notification.stop"` The action which stops playback. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#EXTRA_INSTANCE_ID() = "INSTANCE_ID"` The extra key of the instance id of the player notification manager. |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#PlayerNotificationManager(android.content.Context,java.lang.String,int,androidx.media3.ui.PlayerNotificationManager.MediaDescriptionAdapter,androidx.media3.ui.PlayerNotificationManager.NotificationListener,androidx.media3.ui.PlayerNotificationManager.CustomActionReceiver,int,int,int,int,int,int,int,int,java.lang.String)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html channelId, int notificationId, https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.NotificationListener notificationListener, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver customActionReceiver, int smallIconResourceId, int playActionIconResourceId, int pauseActionIconResourceId, int stopActionIconResourceId, int rewindActionIconResourceId, int fastForwardActionIconResourceId, int previousActionIconResourceId, int nextActionIconResourceId, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html groupKey )` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#invalidate()()` Forces an update of the notification if already started. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setBadgeIconType(int)(int badgeIconType)` Sets the badge icon type of the notification. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setColor(int)(int color)` Sets the accent color of the notification. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setColorized(boolean)(boolean colorized)` Sets whether the notification should be colorized. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setDefaults(int)(int defaults)` Sets the defaults. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setMediaSessionToken(android.media.session.MediaSession.Token)(https://developer.android.com/reference/android/media/session/MediaSession.Token.html token)` Sets the `https://developer.android.com/reference/android/media/session/MediaSession.Token.html`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setPlayer(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Sets the `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setPriority(int)(@https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Priority int priority)` Sets the priority of the notification required for API 25 and lower. |
| `void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setShowPlayButtonIfPlaybackIsSuppressed(boolean)( boolean showPlayButtonIfSuppressed )` Sets whether a play button is shown if playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setSmallIcon(int)(@https://developer.android.com/reference/androidx/annotation/DrawableRes int smallIconResourceId)` Sets the small icon of the notification which is also shown in the system status bar. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseChronometer(boolean)(boolean useChronometer)` Sets whether the elapsed time of the media playback should be displayed. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardAction(boolean)(boolean useFastForwardAction)` Sets whether the fast forward action should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardActionInCompactView(boolean)( boolean useFastForwardActionInCompactView )` Sets whether the fast forward action should also be used in compact view. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)(boolean useNextAction)` Sets whether the next action should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextActionInCompactView(boolean)(boolean useNextActionInCompactView)` If `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)` is `true`, sets whether the next action should also be used in compact view. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePlayPauseActions(boolean)(boolean usePlayPauseActions)` Sets whether the play and pause actions should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)(boolean usePreviousAction)` Sets whether the previous action should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousActionInCompactView(boolean)( boolean usePreviousActionInCompactView )` If `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)` is `true`, sets whether the previous action should also be used in compact view. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseRewindAction(boolean)(boolean useRewindAction)` Sets whether the rewind action should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseRewindActionInCompactView(boolean)(boolean useRewindActionInCompactView)` Sets whether the rewind action should also be used in compact view. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseStopAction(boolean)(boolean useStopAction)` Sets whether the stop action should be used. |
| `final void` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setVisibility(int)(@https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Visibility int visibility)` Sets the visibility of the notification which determines whether and how the notification is shown when the device is in lock screen mode. |

| ### Protected methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#createNotification(androidx.media3.common.Player,androidx.core.app.NotificationCompat.Builder,boolean,android.graphics.Bitmap)( https://developer.android.com/reference/androidx/media3/common/Player player, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder builder, boolean ongoing, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/Bitmap.html largeIcon )` Creates the notification given the current player state. |
| `int[]` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#getActionIndicesForCompactView(java.util.List<java.lang.String>,androidx.media3.common.Player)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html> actionNames, https://developer.android.com/reference/androidx/media3/common/Player player)` Gets an array with the indices of the buttons to be shown in compact mode. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#getActions(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Gets the names and order of the actions to be included in the notification at the current player state. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#getOngoing(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Returns whether the generated notification should be ongoing. |

## Constants

### ACTION_FAST_FORWARD

```
public static final String ACTION_FAST_FORWARD = "androidx.media3.ui.notification.ffwd"
```

The action which fast forwards.

### ACTION_NEXT

```
public static final String ACTION_NEXT = "androidx.media3.ui.notification.next"
```

The action which skips to the next media item.

### ACTION_PAUSE

```
public static final String ACTION_PAUSE = "androidx.media3.ui.notification.pause"
```

The action which pauses playback.

### ACTION_PLAY

```
public static final String ACTION_PLAY = "androidx.media3.ui.notification.play"
```

The action which starts playback.

### ACTION_PREVIOUS

```
public static final String ACTION_PREVIOUS = "androidx.media3.ui.notification.prev"
```

The action which skips to the previous media item.

### ACTION_REWIND

```
public static final String ACTION_REWIND = "androidx.media3.ui.notification.rewind"
```

The action which rewinds.

### ACTION_STOP

```
public static final String ACTION_STOP = "androidx.media3.ui.notification.stop"
```

The action which stops playback.

### EXTRA_INSTANCE_ID

```
public static final String EXTRA_INSTANCE_ID = "INSTANCE_ID"
```

The extra key of the instance id of the player notification manager.

## Protected constructors

### PlayerNotificationManager

```
protected PlayerNotificationManager(
    Context context,
    String channelId,
    int notificationId,
    PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter,
    @Nullable PlayerNotificationManager.NotificationListener notificationListener,
    @Nullable PlayerNotificationManager.CustomActionReceiver customActionReceiver,
    int smallIconResourceId,
    int playActionIconResourceId,
    int pauseActionIconResourceId,
    int stopActionIconResourceId,
    int rewindActionIconResourceId,
    int fastForwardActionIconResourceId,
    int previousActionIconResourceId,
    int nextActionIconResourceId,
    @Nullable String groupKey
)
```

## Public methods

### invalidate

```
public final void invalidate()
```

Forces an update of the notification if already started.

### setBadgeIconType

```
public final void setBadgeIconType(int badgeIconType)
```

Sets the badge icon type of the notification.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setBadgeIconType(int)`.

| Parameters |
|---|---|
| `int badgeIconType` | The badge icon type. |

### setColor

```
public final void setColor(int color)
```

Sets the accent color of the notification.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setColor(int)`.

| Parameters |
|---|---|
| `int color` | The color, in ARGB integer form like the constants in `https://developer.android.com/reference/android/graphics/Color.html`. |

### setColorized

```
public final void setColorized(boolean colorized)
```

Sets whether the notification should be colorized. When set, the color set with `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setColor(int)` will be used as the background color for the notification.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setColorized(boolean)`.

| Parameters |
|---|---|
| `boolean colorized` | Whether to colorize the notification. |

### setDefaults

```
public final void setDefaults(int defaults)
```

Sets the defaults.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setDefaults(int)`.

| Parameters |
|---|---|
| `int defaults` | The default notification options. |

### setMediaSessionToken

```
public final void setMediaSessionToken(MediaSession.Token token)
```

Sets the `https://developer.android.com/reference/android/media/session/MediaSession.Token.html`.

When using `MediaSessionCompat`, this token can be obtained with `
(MediaSession.Token) compatToken.getToken()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/media/session/MediaSession.Token.html token` | The `https://developer.android.com/reference/android/media/session/MediaSession.Token.html`. |

### setPlayer

```
public final void setPlayer(@Nullable Player player)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/Player`.

Setting the player starts a notification immediately unless the player is in `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE()`, in which case the notification is started as soon as the player transitions away from being idle.

If the player is released it must be removed from the manager by calling `
setPlayer(null)`. This will cancel the notification.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player` to use, or `null` to remove the current player. Only players which are accessed on the main thread are supported (` player.getApplicationLooper() == Looper.getMainLooper()`). |

### setPriority

```
public final void setPriority(@PlayerNotificationManager.Priority int priority)
```

Sets the priority of the notification required for API 25 and lower.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setPriority(int)`.

To set the priority for API levels above 25, you can create your own `https://developer.android.com/reference/android/app/NotificationChannel.html` with a given importance level and pass the id of the channel to `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Builder#Builder(android.content.Context,int,java.lang.String,androidx.media3.ui.PlayerNotificationManager.MediaDescriptionAdapter)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Priority int priority` | The priority which can be one of `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_DEFAULT()`, `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_MAX()`, `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_HIGH()`, `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_LOW()` or `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_MIN()`. If not set `https://developer.android.com/reference/androidx/core/app/NotificationCompat#PRIORITY_LOW()` is used by default. Value is one of the following: - `NotificationCompat.PRIORITY_DEFAULT` - `NotificationCompat.PRIORITY_MAX` - `NotificationCompat.PRIORITY_HIGH` - `NotificationCompat.PRIORITY_LOW` - `NotificationCompat.PRIORITY_MIN` <br /> |

### setShowPlayButtonIfPlaybackIsSuppressed

```
public void setShowPlayButtonIfPlaybackIsSuppressed(
    boolean showPlayButtonIfSuppressed
)
```

Sets whether a play button is shown if playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`.

The default is `true`.

| Parameters |
|---|---|
| `boolean showPlayButtonIfSuppressed` | Whether to show a play button if playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`. |

### setSmallIcon

```
public final void setSmallIcon(@DrawableRes int smallIconResourceId)
```

Sets the small icon of the notification which is also shown in the system status bar.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setSmallIcon(int)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/DrawableRes int smallIconResourceId` | The resource id of the small icon. |

### setUseChronometer

```
public final void setUseChronometer(boolean useChronometer)
```

Sets whether the elapsed time of the media playback should be displayed.

Note that this setting only works if all of the following are true:

- The media is `https://developer.android.com/reference/androidx/media3/common/Player#isPlaying()`.
- The media is not `https://developer.android.com/reference/androidx/media3/common/Player#isCurrentMediaItemDynamic()` (like for example a live stream).
- The media is not `https://developer.android.com/reference/androidx/media3/common/Player#isPlayingAd()`.
- The media is played at `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackParameters()`.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setUsesChronometer(boolean)`.

| Parameters |
|---|---|
| `boolean useChronometer` | Whether to use chronometer. |

### setUseFastForwardAction

```
public final void setUseFastForwardAction(boolean useFastForwardAction)
```

Sets whether the fast forward action should be used.

| Parameters |
|---|---|
| `boolean useFastForwardAction` | Whether to use the fast forward action. |

### setUseFastForwardActionInCompactView

```
public final void setUseFastForwardActionInCompactView(
    boolean useFastForwardActionInCompactView
)
```

Sets whether the fast forward action should also be used in compact view. Has no effect if `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_FAST_FORWARD()` is not enabled, for instance if the media is not seekable.

If set to `true`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `boolean useFastForwardActionInCompactView` | Whether to use the fast forward action in compact view. |

### setUseNextAction

```
public final void setUseNextAction(boolean useNextAction)
```

Sets whether the next action should be used.

| Parameters |
|---|---|
| `boolean useNextAction` | Whether to use the next action. |

### setUseNextActionInCompactView

```
public final void setUseNextActionInCompactView(boolean useNextActionInCompactView)
```

If `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)` is `true`, sets whether the next action should also be used in compact view. Has no effect if `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)` is `false`.

If set to `true`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `boolean useNextActionInCompactView` | Whether to use the next action in compact view. |

### setUsePlayPauseActions

```
public final void setUsePlayPauseActions(boolean usePlayPauseActions)
```

Sets whether the play and pause actions should be used.

| Parameters |
|---|---|
| `boolean usePlayPauseActions` | Whether to use play and pause actions. |

### setUsePreviousAction

```
public final void setUsePreviousAction(boolean usePreviousAction)
```

Sets whether the previous action should be used.

| Parameters |
|---|---|
| `boolean usePreviousAction` | Whether to use the previous action. |

### setUsePreviousActionInCompactView

```
public final void setUsePreviousActionInCompactView(
    boolean usePreviousActionInCompactView
)
```

If `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)` is `true`, sets whether the previous action should also be used in compact view. Has no effect if `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)` is `false`.

If set to `true`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUseRewindActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `boolean usePreviousActionInCompactView` | Whether to use the previous action in compact view. |

### setUseRewindAction

```
public final void setUseRewindAction(boolean useRewindAction)
```

Sets whether the rewind action should be used.

| Parameters |
|---|---|
| `boolean useRewindAction` | Whether to use the rewind action. |

### setUseRewindActionInCompactView

```
public final void setUseRewindActionInCompactView(boolean useRewindActionInCompactView)
```

Sets whether the rewind action should also be used in compact view. Has no effect if `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_REWIND()` is not enabled, for instance if the media is not seekable.

If set to `true`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#setUsePreviousActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `boolean useRewindActionInCompactView` | Whether to use the rewind action in compact view. |

### setUseStopAction

```
public final void setUseStopAction(boolean useStopAction)
```

Sets whether the stop action should be used.

| Parameters |
|---|---|
| `boolean useStopAction` | Whether to use the stop action. |

### setVisibility

```
public final void setVisibility(@PlayerNotificationManager.Visibility int visibility)
```

Sets the visibility of the notification which determines whether and how the notification is shown when the device is in lock screen mode.

See `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setVisibility(int)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.Visibility int visibility` | The visibility which must be one of `https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PUBLIC()`, `https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PRIVATE()` or `https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_SECRET()`. Value is one of the following: - `NotificationCompat.VISIBILITY_PRIVATE` - `NotificationCompat.VISIBILITY_PUBLIC` - `NotificationCompat.VISIBILITY_SECRET` <br /> |

## Protected methods

### createNotification

```
protected @Nullable NotificationCompat.Builder createNotification(
    Player player,
    @Nullable NotificationCompat.Builder builder,
    boolean ongoing,
    @Nullable Bitmap largeIcon
)
```

Creates the notification given the current player state.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The player for which state to build a notification. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder builder` | The builder used to build the last notification, or `null`. |
| `boolean ongoing` | Whether the notification should be ongoing. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/Bitmap.html largeIcon` | The large icon to be used. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder` | The `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder` on which to call `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#build()` to obtain the notification, or `null` if no notification should be displayed. |

### getActionIndicesForCompactView

```
protected int[] getActionIndicesForCompactView(List<String> actionNames, Player player)
```

Gets an array with the indices of the buttons to be shown in compact mode.

This method can be overridden. The indices must refer to the list of actions passed as the first parameter.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html> actionNames` | The names of the actions included in the notification. |
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The player for which a notification is being built. |

### getActions

```
protected List<String> getActions(Player player)
```

Gets the names and order of the actions to be included in the notification at the current player state.

The playback and custom actions are combined and placed in the following order if not omitted:

```
  +---+
  | prev | << | play/pause | >> | next | custom actions | stop |
  +---+
```

This method can be safely overridden. However, the names must be of the playback actions `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PAUSE()`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PLAY()`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_FAST_FORWARD()`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_REWIND()`, `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_NEXT()` or `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager#ACTION_PREVIOUS()`, or a key contained in the map returned by `https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#createCustomActions(android.content.Context,int)`. Otherwise the action name is ignored.

### getOngoing

```
protected boolean getOngoing(Player player)
```

Returns whether the generated notification should be ongoing.