Back to Exoplayer

PlayerNotificationManager.CustomActionReceiver (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.CustomActionReceiver.html

latest4.7 KB
Original Source

Package com.google.android.exoplayer2.ui

Interface PlayerNotificationManager.CustomActionReceiver


public static interfacePlayerNotificationManager.CustomActionReceiver

Defines and handles custom actions.

Method Summary

All Methods Instance Methods Abstract Methods | Modifier and Type | Method | Description | | --- | --- | --- | | Map<String,​androidx.core.app.NotificationCompat.Action> | createCustomActions​(Context context, int instanceId) | Gets the actions handled by this receiver. | | List<String> | getCustomActions​(Player player) | Gets the actions to be included in the notification given the current player state. | | void | onCustomAction​(Player player, String action, Intent intent) | Called when a custom action has been received. |

Method Detail

- 

createCustomActions

[Map](https://developer.android.com/reference/java/util/Map.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"),​androidx.core.app.NotificationCompat.Action> createCustomActions​([Context](https://developer.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
                                                                                  int instanceId)

Gets the actions handled by this receiver.

If multiple PlayerNotificationManager instances are in use at the same time, the instanceId must be set as an intent extra with key PlayerNotificationManager.EXTRA_INSTANCE_ID to avoid sending the action to every custom action receiver. It's also necessary to ensure something is different about the actions. This may be any of the Intent attributes considered by Intent.filterEquals(android.content.Intent), or different request code integers when creating the PendingIntents with PendingIntent.getBroadcast(android.content.Context, int, android.content.Intent, int). The easiest approach is to use the instanceId as the request code.

Parameters:context - The Context.instanceId - The instance id of the PlayerNotificationManager.Returns:A map of custom actions.

- 

getCustomActions

[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")> getCustomActions​([Player](../Player.html "interface in com.google.android.exoplayer2")player)

Gets the actions to be included in the notification given the current player state. Parameters:player - The Player for which a notification is being built.Returns:The actions to be included in the notification.

- 

onCustomAction

void onCustomAction​([Player](../Player.html "interface in com.google.android.exoplayer2")player,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")action,[Intent](https://developer.android.com/reference/android/content/Intent.html "class or interface in android.content")intent)

Called when a custom action has been received. Parameters:player - The player.action - The action from Intent.getAction().intent - The received Intent.