Skip to content

How to disable next/prev slot reservation with setMediaButtonPreferences? #2976

Closed

Description

@nift4

I read the note that says setCustomLayout is deprecated, and tried to migrate to setMediaButtonPreferences, however the next/prev slot reservation appeared and I don't want it. It seems it's hardcoded if there is no next/prev button:

legacyExtras.putBoolean(
MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_PREV,
!CommandButton.containsButtonForSlot(customLayout, CommandButton.SLOT_BACK));
legacyExtras.putBoolean(
MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT,
!CommandButton.containsButtonForSlot(customLayout, CommandButton.SLOT_FORWARD));

Am I missing something, or is there no way to disable it?

Activity

  1. tonihei commented on Jan 5, 2026

    @tonihei
    Collaborator

    Could you provide more details on what you want to happen exactly? That is, which buttons do you want to show and where?

    These slot reservation are used for compatibility with the older model only, and the idea is to just define your preferences in the new model without considering how exactly this compatibility layer is implemented. In theory, you shouldn't even need to know these constants exist or when they are set.

  2. nift4 commented on Jan 5, 2026

    @nift4
    ContributorAuthor

    Well, it adds empty space to the notification if it's the first/last playlist item, and I want there to be no empty space.

    I want the default prev/next buttons to show if it's possible to seek prev/next, and otherwise I want them to disappear without leaving empty space.

    edit: I don't have custom buttons that go into these slots.

  3. tonihei commented on Jan 5, 2026

    @tonihei
    Collaborator

    I'm sorry, but I still don't understand what you expect to happen exactly. If you want the button to disappear without being replaced by a custom button and without leaving an empty space, what else should be shown in the UI space instead?

  4. nift4 commented on Jan 5, 2026

    @nift4
    ContributorAuthor

    If I use setCustomLayout(), the seekbar gets bigger to fill the empty space.

  5. tonihei commented on Jan 5, 2026

    @tonihei
    Collaborator

    Thanks for the clarification, I wasn't aware this is happening. This is an unusual UI decision by the system media notification and I guess the desired outcome is always to fill the remaining space with the seek bar if there is nothing else to fill the gap.

    Will see how we can best implement that, but I guess we can remove the flag if there is no other custom button that can accidentally fill the slot.

  6. nift4 commented on Jan 5, 2026

    @nift4
    ContributorAuthor

    if there is no other custom button that can accidentally fill the slot.

    Do you mean SLOT_BACK/SLOT_NEXT or what exactly? Because with setCustomLayout() I have two SLOT_OVERFLOW buttons and I don't set the flag. So the end result is:

    (no next button)

    Image

    (next button)

    Image

    that is what I want to achieve using the new API, and that is what is achieved if the flag is just never set by media3.

  7. tonihei commented on Jan 6, 2026

    @tonihei
    Collaborator

    Thanks, I can definitely see the issue myself now and I still wonder why System UI does not extend the progress bar automatically to fill all the empty space. I'm no UX expert, but it doesn't look like this was ever intended as a design option.

    And yes, you are right, we can probably just never set the flag for NEXT to achieve the desired result. Still need to handle the PREV flag in cases where this slot is meant to stay empty and overflow buttons are present

  8. nift4 commented on Jan 7, 2026

    @nift4
    ContributorAuthor

    Thanks, it works!

  9. locked and limited conversation to collaborators on Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions