MediaNotification.Provider


@UnstableApi
public interface MediaNotification.Provider


Provides media notifications to be posted as notifications that reflect the state of a MediaController and to send media commands to a .

The provider is required to create a notification channel, which is required to show notification for SDK_INT >= 26.

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

Summary

Nested types

Receives updates for a notification.

Public methods

abstract MediaNotification
createNotification(
    MediaSession mediaSession,
    ImmutableList<CommandButton> customLayout,
    MediaNotification.ActionFactory actionFactory,
    MediaNotification.Provider.Callback onNotificationChangedCallback
)

Creates a new MediaNotification.

abstract boolean
handleCustomCommand(MediaSession session, String action, Bundle extras)

Handles a notification's custom command.

Public methods

createNotification

abstract MediaNotification createNotification(
    MediaSession mediaSession,
    ImmutableList<CommandButton> customLayout,
    MediaNotification.ActionFactory actionFactory,
    MediaNotification.Provider.Callback onNotificationChangedCallback
)

Creates a new MediaNotification.

Parameters
MediaSession mediaSession

The media session.

ImmutableList<CommandButton> customLayout

The custom layout set by the session.

MediaNotification.ActionFactory actionFactory

The ActionFactory for creating notification actions.

MediaNotification.Provider.Callback onNotificationChangedCallback

A callback that the provider needs to notify when the notification has changed and needs to be posted again, for example after a bitmap has been loaded asynchronously.

handleCustomCommand

abstract boolean handleCustomCommand(MediaSession session, String action, Bundle extras)

Handles a notification's custom command.

Parameters
MediaSession session

The media session.

String action

The custom command action.

Bundle extras

A bundle set in the custom command, otherwise EMPTY.

Returns
boolean

false if the action should be delivered to the session as a custom command or true if the action has been handled completely by the provider.