-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Custom Browse Actions with Media3 MediaLibraryService #1474
Comments
We are in the process of adding this feature and we can use this issue to track this effort publicly. Unfortunately, we missed that Android Automotive published guidelines for this already without waiting for the Media3 implementation, so apologies for the feature gap. |
@tonihei From my reading about that feature it was for Android Automotive and not Android Auto. Did you meant that or will this be supported on Android Auto too? |
@tonihei thanks for the clarification. Do you know approx. when can we expect this feature? |
Yes, I meant Automotive (fixed my post too). And we can't provide concrete timelines, but unfortunately it won't be part of the upcoming 1.4.0 release. We'll try to get it in as soon as possible afterwards. |
When sending a custom command with `browser.sendCustomCommand` when connected to a legacy browser service, the custom command was delivered to `MediaSessionCompat.Callback.onCustomAction` instead of the service method `onCustomAction`. The difference is that the service version can return an async response with a bundle, while the session callback version doesn't have a return value. Hence, the service method was never called and it wasn't possible to send a reponse or signal an error back to the browser. The resulting `ListanableFuture` simply always immediately resolved to a success. This change overrides `ListenableFuture<SessionResult> sendCustomCommand(SessionCommand command, Bundle args)` in `MediaBrowserImplLegacy` to use the `MediaBrowserCompat` method to send instead of the `MediaControlleCompat` method that was used by the subclass `MediaControllerImplLegacy`. This involves the service callback instead of the session callback and enables `MediaBrowser` to get the actual return value from the legacy service. Issue: #1474 #cherrypick PiperOrigin-RevId: 676519314
Note that unlike the legacy implementation, custom media items commands can be used for any media items with Media3 API. This includes `MediaItem` instances that are received from sources different to `MediaLibraryService` methods. Hence when connected against a Media3 session these custom commands can be used with a `MediaController` as well as with a `MediaBrowser`. Interoperability with `MediaBrowserServiceCompat` will be added in a follow up CL. Issue: #1474 #cherrypick PiperOrigin-RevId: 678782860
The max number of commands for media items of a browser or controller can be configured with `setMaxCommandsForMediaItems(int)` on `MediaController.Builder` and `MediaBrowser.Builder`. An app that has only limited space for displaying commands can hint this limit to the session. A session can receive the value of a connected browser or controller through `getMaxCommandsForMediaItems()` of a `ControllerInfo` that is passed into every callback method. The session can then pick the most sensible commands instead of making the browser app truncating the commands rather randomly. When a `MediaBrowser` is connected against a legacy `MediaBrowserServiceCompat`, the max number of commands is automatically added to the root hints. Conversely, the value passed in with the root hints to `MediaLibraryService` by a legacy `MediaBrowserCompat`, is read into `ControllerInfo` like for a Media3 browser. Issue: #1474 #cherrypick PiperOrigin-RevId: 679076506
When calling `MediaController.getCommandButtonForMediaItem(MediaItem)` command buttons with custom commands that are not available shouldn't be advertised to the controller when connected to a Media3 session. In contrast, when connected to a legacy session, available commands are not enforced when advertising commands. Similarly, when sending a custom commands that is referenced by a command button for media items, sending is permitted without the command being available. This is required because available commands match to custom actions in `PlaybackStateCompat` of the legacy session. Adding commands for media items to custom action of the `PlaybackStateCompat` would interfere with other use cases. Issue: #1474 #cherrypick PiperOrigin-RevId: 683717723
How can we implement same Custom Browse Actions described in here https://developer.android.com/training/cars/media#how_to_implement_custom_browse_actions
with Media3 MediaLibraryService?
The text was updated successfully, but these errors were encountered: