media icon indicating copy to clipboard operation
media copied to clipboard

Media Controllers — Slot reservation

Open DavidEdwardsBL opened this issue 1 year ago • 1 comments

Split from: https://github.com/androidx/media/issues/216

There are flags I would like to set: EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_PREV and EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT.

In the documentation they are listed as (not yet supported with Media3). Is there a timeframe for their implementation?

DavidEdwardsBL avatar May 31 '24 15:05 DavidEdwardsBL

Thanks for your question!

This will be included in the beta of 1.4.0.

The media1 session has an additional extras Bundle in the PlaybackStateCompat that doesn't exist in Media3. 1.4.0 will propagate the already existing session extras to the PlaybackStateCompat as well.

So with 1.4 (starting with beta) you can populate the extras Bundle with the keys above and then call:

mediaLibrarySession.mediaNotificationControllerInfo?.let {
    val extras = Bundle()
    extras.putBoolean(MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT, true)
    extras.putBoolean(MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_PREV, true)
    mediaLibrarySession.setSessionExtras(it, extras)
}

This will propagate the extras to the session extras and the PlaybackStateCompat.extras from where System UI reads them.

Once this is released, the documentation will be updated accordingly. I'll leave this issue open to track this.

marcbaechinger avatar Jun 14 '24 14:06 marcbaechinger

This is implemented with commit 2456669398100730737ea5ef538c62c30a53e05b and is available in 1.4.0.

The properties of the session extras are propagated into the PlaybackState(Compat) of the legacy/platform session where System UI can read them:

mediaLibrarySession.mediaNotificationControllerInfo?.let {
    val extras = Bundle()
    extras.putBoolean(MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT, true)
    extras.putBoolean(MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_PREV, true)
    mediaLibrarySession.setSessionExtras(it, extras)
}

marcbaechinger avatar Jul 28 '24 19:07 marcbaechinger

@marcbaechinger Is that designed to have an impact on Android Auto?

The buttons appear correct now in standard notifications. However, it does not seem to work correctly in Android Auto.

DavidEdwardsBL avatar Jul 29 '24 08:07 DavidEdwardsBL

it does not seem to work correctly in Android Auto.

Can you clarify what your expectation is for for Android Auto? Can you point me to the docs of Android Auto that tell how they deal with for instance MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT, like expected behaviour vs. observed behaviour?

marcbaechinger avatar Aug 13 '24 08:08 marcbaechinger