docs/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.html
Package com.google.android.exoplayer2.ui
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public classPlayerNotificationManagerextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
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 setPlayer(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).
Playback actions can be included or omitted as follows:
usePlayPauseActions - Sets whether the play and pause actions are used.
setUsePlayPauseActions(boolean)trueuseRewindAction - Sets whether the rewind action is used.
setUseRewindAction(boolean)trueuseRewindActionInCompactView - If useRewindAction is true, sets whether the rewind action is also used in compact view (including the lock screen notification). Else does nothing.
setUseRewindActionInCompactView(boolean)falseuseFastForwardAction - Sets whether the fast forward action is used.
setUseFastForwardAction(boolean)trueuseFastForwardActionInCompactView - If useFastForwardAction is true, sets whether the fast forward action is also used in compact view (including the lock screen notification). Else does nothing.
setUseFastForwardActionInCompactView(boolean)falseusePreviousAction - Whether the previous action is used.
setUsePreviousAction(boolean)trueusePreviousActionInCompactView - If usePreviousAction is true, sets whether the previous action is also used in compact view (including the lock screen notification). Else does nothing.
setUsePreviousActionInCompactView(boolean)falseuseNextAction - Whether the next action is used.
setUseNextAction(boolean)trueuseNextActionInCompactView - If useNextAction is true, sets whether the next action is also used in compact view (including the lock screen notification). Else does nothing.
setUseNextActionInCompactView(boolean)falseuseStopAction - Sets whether the stop action is used.
setUseStopAction(boolean)falseThe 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 NotificationCompat.Builder.setSmallIcon(int). A different icon can also be specified programmatically by calling 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 programatically by using the PlayerNotificationManager.Builder.
Unlike the drawables above, the large icon (i.e. the icon passed to NotificationCompat.Builder.setLargeIcon(Bitmap) cannot be overridden in this way. Instead, the large icon is obtained from the PlayerNotificationManager.MediaDescriptionAdapter passed to Builder(Context, int, String, MediaDescriptionAdapter).
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| class | PlayerNotificationManager.BitmapCallback |
Deprecated.
Receives a Bitmap.
|
| static class | PlayerNotificationManager.Builder |
Deprecated.
A builder for PlayerNotificationManager instances.
|
| static interface | PlayerNotificationManager.CustomActionReceiver |
Deprecated.
Defines and handles custom actions.
|
| static interface | PlayerNotificationManager.MediaDescriptionAdapter |
Deprecated.
An adapter to provide content assets of the media currently playing.
|
| static interface | PlayerNotificationManager.NotificationListener |
Deprecated.
A listener for changes to the notification.
|
| static interface | PlayerNotificationManager.Priority |
Deprecated.
Priority of the notification (required for API 25 and lower).
|
| static interface | PlayerNotificationManager.Visibility |
Deprecated.
Visibility of notification on the lock screen. |
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static String | ACTION_FAST_FORWARD |
Deprecated.
The action which fast forwards.
|
| static String | ACTION_NEXT |
Deprecated.
The action which skips to the next media item.
|
| static String | ACTION_PAUSE |
Deprecated.
The action which pauses playback.
|
| static String | ACTION_PLAY |
Deprecated.
The action which starts playback.
|
| static String | ACTION_PREVIOUS |
Deprecated.
The action which skips to the previous media item.
|
| static String | ACTION_REWIND |
Deprecated.
The action which rewinds.
|
| static String | ACTION_STOP |
Deprecated.
The action which stops playback.
|
| static String | EXTRA_INSTANCE_ID |
Deprecated.
The extra key of the instance id of the player notification manager. |
Constructors | Modifier | Constructor | Description |
| --- | --- | --- |
| protected | PlayerNotificationManager(Context context, String channelId, int notificationId, PlayerNotificationManager.MediaDescriptionAdapter mediaDescriptionAdapter, PlayerNotificationManager.NotificationListener notificationListener, PlayerNotificationManager.CustomActionReceiver customActionReceiver, int smallIconResourceId, int playActionIconResourceId, int pauseActionIconResourceId, int stopActionIconResourceId, int rewindActionIconResourceId, int fastForwardActionIconResourceId, int previousActionIconResourceId, int nextActionIconResourceId, String groupKey) |
Deprecated.
|
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| protected androidx.core.app.NotificationCompat.Builder | createNotification(Player player, androidx.core.app.NotificationCompat.Builder builder, boolean ongoing, Bitmap largeIcon) |
Deprecated.
Creates the notification given the current player state.
|
| protected int[] | getActionIndicesForCompactView(List<String> actionNames, Player player) |
Deprecated.
Gets an array with the indices of the buttons to be shown in compact mode.
|
| protected List<String> | getActions(Player player) |
Deprecated.
Gets the names and order of the actions to be included in the notification at the current player state.
|
| protected boolean | getOngoing(Player player) |
Deprecated.
Returns whether the generated notification should be ongoing.
|
| void | invalidate() |
Deprecated.
Forces an update of the notification if already started.
|
| void | setBadgeIconType(int badgeIconType) |
Deprecated.
Sets the badge icon type of the notification.
|
| void | setColor(int color) |
Deprecated.
Sets the accent color of the notification.
|
| void | setColorized(boolean colorized) |
Deprecated.
Sets whether the notification should be colorized.
|
| void | setDefaults(int defaults) |
Deprecated.
Sets the defaults.
|
| void | setMediaSessionToken(android.support.v4.media.session.MediaSessionCompat.Token token) |
Deprecated.
Sets the MediaSessionCompat.Token.
|
| void | setPlayer(Player player) |
Deprecated.
Sets the Player.
|
| void | setPriority(@com.google.android.exoplayer2.ui.PlayerNotificationManager.Priority int priority) |
Deprecated.
Sets the priority of the notification required for API 25 and lower.
|
| void | setSmallIcon(int smallIconResourceId) |
Deprecated.
Sets the small icon of the notification which is also shown in the system status bar.
|
| void | setUseChronometer(boolean useChronometer) |
Deprecated.
Sets whether the elapsed time of the media playback should be displayed.
|
| void | setUseFastForwardAction(boolean useFastForwardAction) |
Deprecated.
Sets whether the fast forward action should be used.
|
| void | setUseFastForwardActionInCompactView(boolean useFastForwardActionInCompactView) |
Deprecated.
Sets whether the fast forward action should also be used in compact view.
|
| void | setUseNextAction(boolean useNextAction) |
Deprecated.
Sets whether the next action should be used.
|
| void | setUseNextActionInCompactView(boolean useNextActionInCompactView) |
Deprecated.
If useNextAction is true, sets whether the next action should also be used in compact view.
|
| void | setUsePlayPauseActions(boolean usePlayPauseActions) |
Deprecated.
Sets whether the play and pause actions should be used.
|
| void | setUsePreviousAction(boolean usePreviousAction) |
Deprecated.
Sets whether the previous action should be used.
|
| void | setUsePreviousActionInCompactView(boolean usePreviousActionInCompactView) |
Deprecated.
If usePreviousAction is true, sets whether the previous action should also be used in compact view.
|
| void | setUseRewindAction(boolean useRewindAction) |
Deprecated.
Sets whether the rewind action should be used.
|
| void | setUseRewindActionInCompactView(boolean useRewindActionInCompactView) |
Deprecated.
Sets whether the rewind action should also be used in compact view.
|
| void | setUseStopAction(boolean useStopAction) |
Deprecated.
Sets whether the stop action should be used.
|
| void | setVisibility(@com.google.android.exoplayer2.ui.PlayerNotificationManager.Visibility int visibility) |
Deprecated.
Sets the visibility of the notification which determines whether and how the notification is shown when the device is in lock screen mode. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_PLAY
Deprecated.
The action which starts playback. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_PAUSE
Deprecated.
The action which pauses playback. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_PREVIOUS
Deprecated.
The action which skips to the previous media item. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_NEXT
Deprecated.
The action which skips to the next media item. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_FAST_FORWARD
Deprecated.
The action which fast forwards. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_REWIND
Deprecated.
The action which rewinds. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ACTION_STOP
Deprecated.
The action which stops playback. See Also:Constant Field Values
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")EXTRA_INSTANCE_ID
Deprecated.
The extra key of the instance id of the player notification manager. See Also:Constant Field Values
-
protected PlayerNotificationManager([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")channelId,
int notificationId,[PlayerNotificationManager.MediaDescriptionAdapter](PlayerNotificationManager.MediaDescriptionAdapter.html "interface in com.google.android.exoplayer2.ui")mediaDescriptionAdapter,
@Nullable[PlayerNotificationManager.NotificationListener](PlayerNotificationManager.NotificationListener.html "interface in com.google.android.exoplayer2.ui")notificationListener,
@Nullable[PlayerNotificationManager.CustomActionReceiver](PlayerNotificationManager.CustomActionReceiver.html "interface in com.google.android.exoplayer2.ui")customActionReceiver,
int smallIconResourceId,
int playActionIconResourceId,
int pauseActionIconResourceId,
int stopActionIconResourceId,
int rewindActionIconResourceId,
int fastForwardActionIconResourceId,
int previousActionIconResourceId,
int nextActionIconResourceId,
@Nullable[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")groupKey)
Deprecated.
-
public final void setPlayer(@Nullable[Player](../Player.html "interface in com.google.android.exoplayer2")player)
Deprecated.
Sets the Player.
Setting the player starts a notification immediately unless the player is in 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 - The 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()).
-
public final void setUseNextAction(boolean useNextAction)
Deprecated.
Sets whether the next action should be used.
Parameters:useNextAction - Whether to use the next action.
-
public final void setUsePreviousAction(boolean usePreviousAction)
Deprecated.
Sets whether the previous action should be used.
Parameters:usePreviousAction - Whether to use the previous action.
-
public final void setUseNextActionInCompactView(boolean useNextActionInCompactView)
Deprecated.
If useNextAction is true, sets whether the next action should also be used in compact view. Has no effect if useNextAction is false.
If set to true, setUseFastForwardActionInCompactView is set to false.
Parameters:useNextActionInCompactView - Whether to use the next action in compact view.
-
public final void setUsePreviousActionInCompactView(boolean usePreviousActionInCompactView)
Deprecated.
If usePreviousAction is true, sets whether the previous action should also be used in compact view. Has no effect if usePreviousAction is false.
If set to true, setUseRewindActionInCompactView is set to false.
Parameters:usePreviousActionInCompactView - Whether to use the previous action in compact view.
-
public final void setUseFastForwardAction(boolean useFastForwardAction)
Deprecated.
Sets whether the fast forward action should be used.
Parameters:useFastForwardAction - Whether to use the fast forward action.
-
public final void setUseRewindAction(boolean useRewindAction)
Deprecated.
Sets whether the rewind action should be used.
Parameters:useRewindAction - Whether to use the rewind action.
-
public final void setUseFastForwardActionInCompactView(boolean useFastForwardActionInCompactView)
Deprecated.
Sets whether the fast forward action should also be used in compact view. Has no effect if ACTION_FAST_FORWARD is not enabled, for instance if the media is not seekable.
If set to true, setUseNextActionInCompactView is set to false.
Parameters:useFastForwardActionInCompactView - Whether to use the fast forward action in compact view.
-
public final void setUseRewindActionInCompactView(boolean useRewindActionInCompactView)
Deprecated.
Sets whether the rewind action should also be used in compact view. Has no effect if ACTION_REWIND is not enabled, for instance if the media is not seekable.
If set to true, setUsePreviousActionInCompactView is set to false.
Parameters:useRewindActionInCompactView - Whether to use the rewind action in compact view.
-
public final void setUsePlayPauseActions(boolean usePlayPauseActions)
Deprecated.
Sets whether the play and pause actions should be used.
Parameters:usePlayPauseActions - Whether to use play and pause actions.
-
public final void setUseStopAction(boolean useStopAction)
Deprecated.
Sets whether the stop action should be used.
Parameters:useStopAction - Whether to use the stop action.
-
public final void setMediaSessionToken(android.support.v4.media.session.MediaSessionCompat.Token token)
Deprecated.
Sets the MediaSessionCompat.Token.
Parameters:token - The MediaSessionCompat.Token.
-
public final void setBadgeIconType(int badgeIconType)
Deprecated.
Sets the badge icon type of the notification.
See NotificationCompat.Builder.setBadgeIconType(int).
Parameters:badgeIconType - The badge icon type.
-
public final void setColorized(boolean colorized)
Deprecated.
Sets whether the notification should be colorized. When set, the color set with setColor(int) will be used as the background color for the notification.
See NotificationCompat.Builder.setColorized(boolean).
Parameters:colorized - Whether to colorize the notification.
-
public final void setDefaults(int defaults)
Deprecated.
Sets the defaults.
See NotificationCompat.Builder.setDefaults(int).
Parameters:defaults - The default notification options.
-
public final void setColor(int color)
Deprecated.
Sets the accent color of the notification.
See NotificationCompat.Builder.setColor(int).
Parameters:color - The color, in ARGB integer form like the constants in Color.
-
public final void setPriority(@com.google.android.exoplayer2.ui.PlayerNotificationManager.Priority int priority)
Deprecated.
Sets the priority of the notification required for API 25 and lower.
See NotificationCompat.Builder.setPriority(int).
To set the priority for API levels above 25, you can create your own NotificationChannel with a given importance level and pass the id of the channel to Builder(Context, int, String, MediaDescriptionAdapter).
Parameters:priority - The priority which can be one of NotificationCompat.PRIORITY_DEFAULT, NotificationCompat.PRIORITY_MAX, NotificationCompat.PRIORITY_HIGH, NotificationCompat.PRIORITY_LOW or NotificationCompat.PRIORITY_MIN. If not set NotificationCompat.PRIORITY_LOW is used by default.
-
public final void setSmallIcon(@DrawableRes
int smallIconResourceId)
Deprecated.
Sets the small icon of the notification which is also shown in the system status bar.
See NotificationCompat.Builder.setSmallIcon(int).
Parameters:smallIconResourceId - The resource id of the small icon.
-
public final void setUseChronometer(boolean useChronometer)
Deprecated.
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 [`actively playing`](../Player.html#isPlaying()).
- The media is not [`dynamically changing its
duration`](../Player.html#isCurrentMediaItemDynamic()) (like for example a live stream).
- The media is not [`interrupted by an ad`](../Player.html#isPlayingAd()).
- The media is played at [`regular speed`](../Player.html#getPlaybackParameters()).
- The device is running at least API 21 (Lollipop).
See NotificationCompat.Builder.setUsesChronometer(boolean).
Parameters:useChronometer - Whether to use chronometer.
-
public final void setVisibility(@com.google.android.exoplayer2.ui.PlayerNotificationManager.Visibility int visibility)
Deprecated.
Sets the visibility of the notification which determines whether and how the notification is shown when the device is in lock screen mode.
See NotificationCompat.Builder.setVisibility(int).
Parameters:visibility - The visibility which must be one of NotificationCompat.VISIBILITY_PUBLIC, NotificationCompat.VISIBILITY_PRIVATE or NotificationCompat.VISIBILITY_SECRET.
-
public final void invalidate()
Deprecated.
Forces an update of the notification if already started.
-
@Nullable
protected androidx.core.app.NotificationCompat.Builder createNotification([Player](../Player.html "interface in com.google.android.exoplayer2")player,
@Nullable
androidx.core.app.NotificationCompat.Builder builder,
boolean ongoing,
@Nullable[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html "class or interface in android.graphics")largeIcon)
Deprecated.
Creates the notification given the current player state.
Parameters:player - The player for which state to build a notification.builder - The builder used to build the last notification, or null. Re-using the builder when possible can prevent notification flicker when Util#SDK_INT < 21.ongoing - Whether the notification should be ongoing.largeIcon - The large icon to be used.Returns:The NotificationCompat.Builder on which to call NotificationCompat.Builder.build() to obtain the notification, or null if no notification should be displayed.
-
protected[List](https://developer.android.com/reference/java/util/List.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> getActions([Player](../Player.html "interface in com.google.android.exoplayer2")player)
Deprecated.
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 ACTION_PAUSE, ACTION_PLAY, ACTION_FAST_FORWARD, ACTION_REWIND, ACTION_NEXT or ACTION_PREVIOUS, or a key contained in the map returned by PlayerNotificationManager.CustomActionReceiver.createCustomActions(Context, int). Otherwise the action name is ignored.
-
protected int[] getActionIndicesForCompactView([List](https://developer.android.com/reference/java/util/List.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> actionNames,[Player](../Player.html "interface in com.google.android.exoplayer2")player)
Deprecated.
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 - The names of the actions included in the notification.player - The player for which a notification is being built.
-
protected boolean getOngoing([Player](../Player.html "interface in com.google.android.exoplayer2")player)
Deprecated.
Returns whether the generated notification should be ongoing.