PlaybackNotificationImpl

Base class for creating and updating a media-style notification.

Action customization

Playback actions can be included or omitted as follows:

  • usePlayPauseActions - Sets whether the play and pause actions are used.

  • Corresponding setter: PlaybackNotificationConfig.setUsePlayPauseActions

  • Default: true

  • useRewindAction - Sets whether the rewind action is used.

  • Corresponding setter: PlaybackNotificationConfig.setUseRewindAction

  • 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: PlaybackNotificationConfig.setUseRewindActionInCompactView

  • Default: false

  • useFastForwardAction - Sets whether the fast forward action is used.

  • Corresponding setter: PlaybackNotificationConfig.setUseFastForwardAction

  • 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: PlaybackNotificationConfig.setUseFastForwardActionInCompactView

  • Default: false

  • usePreviousAction - Whether the previous action is used.

  • Corresponding setter: PlaybackNotificationConfig.setUsePreviousAction

  • 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: PlaybackNotificationConfig.setUsePreviousActionInCompactView

  • Default: false

  • useNextAction - Whether the next action is used.

  • Corresponding setter: PlaybackNotificationConfig.setUseNextAction

  • 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: PlaybackNotificationConfig.setUseNextActionInCompactView

  • Default: false

Overriding drawables

The action icons can be set programatically by using the PlaybackNotificationConfig. The large icon (i.e. the icon passed to Notification.Builder.setLargeIcon is obtained from the MediaDescriptionAdapter passed to PlaybackNotificationConfig.setAdapter

    notification.setConfig(new MediaPlaybackNotification.Config(this)
        .setSmallIcon(R.mipmap.ic_launcher)
        .setUseNextAction(false)
        .setPriority(NotificationCompat.PRIORITY_MAX)
.        setAdapter(new MediaPlaybackNotification.MediaDescriptionAdapter() {
            @Override
            public CharSequence getCurrentContentTitle(MediaPlayback playback) {
                return "Your custom title";
            }
            @Nullable
            @Override
            public Bitmap getCurrentLargeIcon(MediaPlayback playback, BitmapCallback callback) {
                // TODO: return your bitmap
            }
        })
    );
*

See also

PlaybackNotificationConfig

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Extras

Extras set on the PendingIntent in the default implementation of the MediaDescriptionAdapter.createCurrentContentIntent.

Functions

Link copied to clipboard
abstract fun cancel()

Cancels the notification by setting the player to null.

Link copied to clipboard
open fun getStreamTypes(): Array<<Error class: unknown class>>

Get the supported stream types for showing this notification.

Link copied to clipboard
abstract fun isVisible(): Boolean

Check is the notification is showing.

Link copied to clipboard
abstract fun setConfig(config: <Error class: unknown class>)

Configure and customize the notification shown for playback.

Link copied to clipboard
open fun setStreamTypes(vararg types: <Error class: unknown class>)

Set the stream types to show notifications for.

Link copied to clipboard
abstract fun show(): Boolean

Starts a notification immediately unless the player is in an idle state, in which case the notification is started as soon as the player transitions away from being idle.