MediaNotification.ActionFactory


@UnstableApi
interface MediaNotification.ActionFactory


Creates actions and pending intents for notifications.

All methods will be called on the application thread of the Player associated with the MediaSession the notification is provided for.

Summary

Public functions

NotificationCompat.Action!
createCustomAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    customAction: String!,
    extras: Bundle!
)

Creates a NotificationCompat.Action for a notification with a custom action.

NotificationCompat.Action!
createCustomActionFromCustomCommandButton(
    mediaSession: MediaSession!,
    customCommandButton: CommandButton!
)

Creates a NotificationCompat.Action for a notification from a custom command button.

NotificationCompat.Action!
createMediaAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    @Player.Command command: Int
)

Creates a NotificationCompat.Action for a notification.

PendingIntent!
createMediaActionPendingIntent(
    mediaSession: MediaSession!,
    @Player.Command command: Long
)

Creates a PendingIntent for a media action that will be handled by the library.

Public functions

createCustomAction

fun createCustomAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    customAction: String!,
    extras: Bundle!
): NotificationCompat.Action!

Creates a NotificationCompat.Action for a notification with a custom action. Actions created with this method are not expected to be handled by the library and will be forwarded to the notification provider that provided them.

Parameters
mediaSession: MediaSession!

The media session to which the action will be sent.

icon: IconCompat!

The icon to show for this action.

title: CharSequence!

The title of the action.

customAction: String!

The custom action set.

extras: Bundle!

Extras to be included in the action.

createCustomActionFromCustomCommandButton

fun createCustomActionFromCustomCommandButton(
    mediaSession: MediaSession!,
    customCommandButton: CommandButton!
): NotificationCompat.Action!

Creates a NotificationCompat.Action for a notification from a custom command button. Actions created with this method are not expected to be handled by the library and will be forwarded to the notification provider that provided them.

The returned NotificationCompat.Action will have a PendingIntent with the extras from customExtras. Accordingly the command's extras will be passed to handleCustomCommand when the action is executed.

Parameters
mediaSession: MediaSession!

The media session to which the action will be sent.

customCommandButton: CommandButton!

A custom command button.

createMediaAction

fun createMediaAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    @Player.Command command: Int
): NotificationCompat.Action!

Creates a NotificationCompat.Action for a notification. These actions will be handled by the library.

Parameters
mediaSession: MediaSession!

The media session to which the action will be sent.

icon: IconCompat!

The icon to show for this action.

title: CharSequence!

The title of the action.

@Player.Command command: Int

A command to send when users trigger this action.

createMediaActionPendingIntent

fun createMediaActionPendingIntent(
    mediaSession: MediaSession!,
    @Player.Command command: Long
): PendingIntent!

Creates a PendingIntent for a media action that will be handled by the library.

Parameters
mediaSession: MediaSession!

The media session to which the action will be sent.

@Player.Command command: Long

The intent's command.