# 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
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/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUsePlayPauseActions(boolean)`
  - Default: `true`
- **`useRewindAction`** - Sets whether the rewind action is used.
  - Corresponding setter: `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUseRewindActionInCompactView(boolean)`
  - Default: `false`
- **`useFastForwardAction`** - Sets whether the fast forward action is used.
  - Corresponding setter: `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUseFastForwardActionInCompactView(boolean)`
  - Default: `false`
- **`usePreviousAction`** - Whether the previous action is used.
  - Corresponding setter: `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUsePreviousActionInCompactView(boolean)`
  - Default: `false`
- **`useNextAction`** - Whether the next action is used.
  - Corresponding setter: `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUseNextActionInCompactView(boolean)`
  - Default: `false`
- **`useStopAction`** - Sets whether the stop action is used.
  - Corresponding setter: `https://developer.android.com/reference/kotlin/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/kotlin/androidx/core/app/NotificationCompat.Builder#setSmallIcon(int)`. A different icon can also be specified programmatically by calling `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager.Builder`.

Unlike the drawables above, the large icon (i.e. the icon passed to `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter` passed to `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setMediaSessionToken(android.media.session.MediaSession.Token)`.

## Summary

| ### Nested types |
|---|
| `inner class https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.BitmapCallback` Receives a `https://developer.android.com/reference/android/graphics/Bitmap.html`. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.Builder` A builder for `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager` instances. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver` Defines and handles custom actions. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter` An adapter to provide content assets of the media currently playing. |
| `interface https://developer.android.com/reference/kotlin/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/kotlin/androidx/annotation/IntDef(value = [https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.PRIORITY_DEFAULT, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.PRIORITY_MAX, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.PRIORITY_HIGH, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.PRIORITY_LOW, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.PRIORITY_MIN]) annotation https://developer.android.com/reference/kotlin/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/kotlin/androidx/annotation/IntDef(value = [https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.VISIBILITY_PRIVATE, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.VISIBILITY_PUBLIC, https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.VISIBILITY_SECRET]) annotation https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.Visibility` Visibility of notification on the lock screen. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_FAST_FORWARD() = "androidx.media3.ui.notification.ffwd"` The action which fast forwards. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_NEXT() = "androidx.media3.ui.notification.next"` The action which skips to the next media item. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PAUSE() = "androidx.media3.ui.notification.pause"` The action which pauses playback. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PLAY() = "androidx.media3.ui.notification.play"` The action which starts playback. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PREVIOUS() = "androidx.media3.ui.notification.prev"` The action which skips to the previous media item. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_REWIND() = "androidx.media3.ui.notification.rewind"` The action which rewinds. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_STOP() = "androidx.media3.ui.notification.stop"` The action which stops playback. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/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/kotlin/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)( context: https://developer.android.com/reference/android/content/Context.html!, channelId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, notificationId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, mediaDescriptionAdapter: https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.MediaDescriptionAdapter!, notificationListener: https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.NotificationListener?, customActionReceiver: https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver?, smallIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, playActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, pauseActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, stopActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, rewindActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, fastForwardActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, previousActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, nextActionIconResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, groupKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? )` |

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

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

## Constants

### ACTION_FAST_FORWARD

```
const val ACTION_FAST_FORWARD = "androidx.media3.ui.notification.ffwd": String!
```

The action which fast forwards.

### ACTION_NEXT

```
const val ACTION_NEXT = "androidx.media3.ui.notification.next": String!
```

The action which skips to the next media item.

### ACTION_PAUSE

```
const val ACTION_PAUSE = "androidx.media3.ui.notification.pause": String!
```

The action which pauses playback.

### ACTION_PLAY

```
const val ACTION_PLAY = "androidx.media3.ui.notification.play": String!
```

The action which starts playback.

### ACTION_PREVIOUS

```
const val ACTION_PREVIOUS = "androidx.media3.ui.notification.prev": String!
```

The action which skips to the previous media item.

### ACTION_REWIND

```
const val ACTION_REWIND = "androidx.media3.ui.notification.rewind": String!
```

The action which rewinds.

### ACTION_STOP

```
const val ACTION_STOP = "androidx.media3.ui.notification.stop": String!
```

The action which stops playback.

### EXTRA_INSTANCE_ID

```
const val EXTRA_INSTANCE_ID = "INSTANCE_ID": String!
```

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

## Protected constructors

### PlayerNotificationManager

```
protected PlayerNotificationManager(
    context: Context!,
    channelId: String!,
    notificationId: Int,
    mediaDescriptionAdapter: PlayerNotificationManager.MediaDescriptionAdapter!,
    notificationListener: PlayerNotificationManager.NotificationListener?,
    customActionReceiver: PlayerNotificationManager.CustomActionReceiver?,
    smallIconResourceId: Int,
    playActionIconResourceId: Int,
    pauseActionIconResourceId: Int,
    stopActionIconResourceId: Int,
    rewindActionIconResourceId: Int,
    fastForwardActionIconResourceId: Int,
    previousActionIconResourceId: Int,
    nextActionIconResourceId: Int,
    groupKey: String?
)
```

## Public functions

### invalidate

```
fun invalidate(): Unit
```

Forces an update of the notification if already started.

### setBadgeIconType

```
fun setBadgeIconType(badgeIconType: Int): Unit
```

Sets the badge icon type of the notification.

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

| Parameters |
|---|---|
| `badgeIconType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The badge icon type. |

### setColor

```
fun setColor(color: Int): Unit
```

Sets the accent color of the notification.

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

| Parameters |
|---|---|
| `color: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The color, in ARGB integer form like the constants in `https://developer.android.com/reference/android/graphics/Color.html`. |

### setColorized

```
fun setColorized(colorized: Boolean): Unit
```

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

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

| Parameters |
|---|---|
| `colorized: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to colorize the notification. |

### setDefaults

```
fun setDefaults(defaults: Int): Unit
```

Sets the defaults.

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

| Parameters |
|---|---|
| `defaults: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The default notification options. |

### setMediaSessionToken

```
fun setMediaSessionToken(token: MediaSession.Token!): Unit
```

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 |
|---|---|
| `token: https://developer.android.com/reference/android/media/session/MediaSession.Token.html!` | The `https://developer.android.com/reference/android/media/session/MediaSession.Token.html`. |

### setPlayer

```
fun setPlayer(player: Player?): Unit
```

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

Setting the player starts a notification immediately unless the player is in `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?` | The `https://developer.android.com/reference/kotlin/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

```
fun setPriority(@PlayerNotificationManager.Priority priority: Int): Unit
```

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

See `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager.Builder#Builder(android.content.Context,int,java.lang.String,androidx.media3.ui.PlayerNotificationManager.MediaDescriptionAdapter)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.Priority priority: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The priority which can be one of `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#PRIORITY_DEFAULT()`, `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#PRIORITY_MAX()`, `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#PRIORITY_HIGH()`, `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#PRIORITY_LOW()` or `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#PRIORITY_MIN()`. If not set `https://developer.android.com/reference/kotlin/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

```
fun setShowPlayButtonIfPlaybackIsSuppressed(
    showPlayButtonIfSuppressed: Boolean
): Unit
```

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

The default is `true`.

| Parameters |
|---|---|
| `showPlayButtonIfSuppressed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to show a play button if playback is `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlaybackSuppressionReason()`. |

### setSmallIcon

```
fun setSmallIcon(smallIconResourceId: @DrawableRes Int): Unit
```

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

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

| Parameters |
|---|---|
| `smallIconResourceId: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource id of the small icon. |

### setUseChronometer

```
fun setUseChronometer(useChronometer: Boolean): Unit
```

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

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

| Parameters |
|---|---|
| `useChronometer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use chronometer. |

### setUseFastForwardAction

```
fun setUseFastForwardAction(useFastForwardAction: Boolean): Unit
```

Sets whether the fast forward action should be used.

| Parameters |
|---|---|
| `useFastForwardAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the fast forward action. |

### setUseFastForwardActionInCompactView

```
fun setUseFastForwardActionInCompactView(
    useFastForwardActionInCompactView: Boolean
): Unit
```

Sets whether the fast forward action should also be used in compact view. Has no effect if `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUseNextActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `useFastForwardActionInCompactView: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the fast forward action in compact view. |

### setUseNextAction

```
fun setUseNextAction(useNextAction: Boolean): Unit
```

Sets whether the next action should be used.

| Parameters |
|---|---|
| `useNextAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the next action. |

### setUseNextActionInCompactView

```
fun setUseNextActionInCompactView(useNextActionInCompactView: Boolean): Unit
```

If `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUseNextAction(boolean)` is `false`.

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

| Parameters |
|---|---|
| `useNextActionInCompactView: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the next action in compact view. |

### setUsePlayPauseActions

```
fun setUsePlayPauseActions(usePlayPauseActions: Boolean): Unit
```

Sets whether the play and pause actions should be used.

| Parameters |
|---|---|
| `usePlayPauseActions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use play and pause actions. |

### setUsePreviousAction

```
fun setUsePreviousAction(usePreviousAction: Boolean): Unit
```

Sets whether the previous action should be used.

| Parameters |
|---|---|
| `usePreviousAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the previous action. |

### setUsePreviousActionInCompactView

```
fun setUsePreviousActionInCompactView(
    usePreviousActionInCompactView: Boolean
): Unit
```

If `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUsePreviousAction(boolean)` is `false`.

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

| Parameters |
|---|---|
| `usePreviousActionInCompactView: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the previous action in compact view. |

### setUseRewindAction

```
fun setUseRewindAction(useRewindAction: Boolean): Unit
```

Sets whether the rewind action should be used.

| Parameters |
|---|---|
| `useRewindAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the rewind action. |

### setUseRewindActionInCompactView

```
fun setUseRewindActionInCompactView(useRewindActionInCompactView: Boolean): Unit
```

Sets whether the rewind action should also be used in compact view. Has no effect if `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/ui/PlayerNotificationManager#setUsePreviousActionInCompactView(boolean)` is set to false.

| Parameters |
|---|---|
| `useRewindActionInCompactView: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the rewind action in compact view. |

### setUseStopAction

```
fun setUseStopAction(useStopAction: Boolean): Unit
```

Sets whether the stop action should be used.

| Parameters |
|---|---|
| `useStopAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the stop action. |

### setVisibility

```
fun setVisibility(@PlayerNotificationManager.Visibility visibility: Int): Unit
```

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/kotlin/androidx/core/app/NotificationCompat.Builder#setVisibility(int)`.

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

## Protected functions

### createNotification

```
protected fun createNotification(
    player: Player!,
    builder: NotificationCompat.Builder?,
    ongoing: Boolean,
    largeIcon: Bitmap?
): NotificationCompat.Builder?
```

Creates the notification given the current player state.

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

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

### getActionIndicesForCompactView

```
protected fun getActionIndicesForCompactView(
    actionNames: (Mutable)List<String!>!,
    player: Player!
): Array<Int>!
```

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 |
|---|---|
| `actionNames: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | The names of the actions included in the notification. |
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The player for which a notification is being built. |

### getActions

```
protected fun getActions(player: Player!): (Mutable)List<String!>!
```

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:

```kotlin
  +---+
  | 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/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PAUSE()`, `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PLAY()`, `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_FAST_FORWARD()`, `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_REWIND()`, `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_NEXT()` or `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager#ACTION_PREVIOUS()`, or a key contained in the map returned by `https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.CustomActionReceiver#createCustomActions(android.content.Context,int)`. Otherwise the action name is ignored.

### getOngoing

```
protected fun getOngoing(player: Player!): Boolean
```

Returns whether the generated notification should be ongoing.