Skip to content
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

How to show a stop button in the notification with Media3 #200

Closed
pawaom opened this issue Nov 2, 2022 · 6 comments
Closed

How to show a stop button in the notification with Media3 #200

pawaom opened this issue Nov 2, 2022 · 6 comments
Assignees
Labels

Comments

@pawaom
Copy link

pawaom commented Nov 2, 2022

How to show PlayerNotificationManager useStopAction in media3 ,

Earlier we used to impalement the PlayerNotification and use useStopAction to show the stop button, how can we do the same in media3

@marcbaechinger
Copy link
Contributor

I think you can to do a custom command for the stop action. The custom command is reflected on all API levels either by adding an action to the notification or by replicating the custom Media3 commands to a media1 custom action in the legacy session.

This comment of issue #38 explains with code samples how you can do custom commands.

@Symon265
Copy link

Symon265 commented Nov 2, 2022 via email

@marcbaechinger
Copy link
Contributor

@Symon265 The comment in issue #38 has sample code regarding custom commands.

If you are asking for general sample code or documentation, I'd look into the session demo app that implements a MediaLibraryService. The documentation currently published on android.developers.com can be found here. This includes a migration guide that helps understand what needs to be done when migrating from a MediaBrowserService.

@pawaom
Copy link
Author

pawaom commented Nov 3, 2022

I can understand if we need custom actions like add to favorite or other such functionality supported by custom actions, but
PlayerNotificationManager useStopAction was an inbuild functionality in exoplayer like this

fUv3J

Why should we use custom action for an inbuild functionality

@marcbaechinger
Copy link
Contributor

On Android 13, the mini player that is created by System UI is based on the media session. This mini player does not support a stop button. If you want the mini player to show a stop button, then you need to do a custom command.

@marcbaechinger marcbaechinger changed the title How to show PlayerNotificationManager useStopAction in media3 How to show a stop button in the notification with Media3 Nov 3, 2022
@marcbaechinger
Copy link
Contributor

I'm closing this issue because it is answered as to use a custom layout with a custom stop SessionCommand. The Media3 library makes sure it lands either on the Notification or the mini player depending on the OS of the device and the targetSdkVersion of the app.

Please re-open as needed.

@androidx androidx locked and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants