Skip to content

Add seekNext and seekPrev commandbuttons to the Android 12 "Compact" notification by default #410

Description

@tzugen

Currently the "compact" notification in Android 12 using the DefaultMediaNotificationProvider shows only the Play/Pause button.

Our users frequently requested it contains the seek buttons as well, so we added them by assigning a COMMAND_KEY_COMPACT_VIEW_INDEX to them.

I would propose that the seek buttons get this flag by default as it seems to be most common that the basic buttons of a media player are prev, play/pause, and next.

For reference our custom class:

class CustomNotificationProvider(ctx: Context) :
    DefaultMediaNotificationProvider(ctx),
    KoinComponent {

    // By default the skip buttons are not shown in compact view. 
    // We add the COMMAND_KEY_COMPACT_VIEW_INDEX to show them
    override fun getMediaButtons(
        session: MediaSession,
        playerCommands: Player.Commands,
        customLayout: ImmutableList<CommandButton>,
        playWhenReady: Boolean
    ): ImmutableList<CommandButton> {
        val commands = super.getMediaButtons(session, playerCommands, customLayout, playWhenReady)

        commands.forEachIndexed { index, command ->
            command.extras.putInt(COMMAND_KEY_COMPACT_VIEW_INDEX, index)
        }

        return commands
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions