question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PlayerNotificationManager: customizeable icons

See original GitHub issue

Use case description

I’d like to customize the icons currently statically fixed in PlayerNotificationManager, more specifically I’d customize ACTION_REWIND and ACTION_FAST_FORWARD but I believe that all icons should be customizable.

I’d be happy to contribute and create a PR with a proposed solution from below or any other proposed solution. I also wanted to write some documentation for [PlayerNotificationManager] for https://exoplayer.dev/ since I struggled reading through issues and code but couldn’t find where that was possible.

Proposed solution

  • Accept a POJO or Map<String, NotificationCompat.Action> in the constructor to specify resId
Alternative solutions
  • Allow CustomActionReceiver to override the default actions. related code.
  • Elaborate CustomActionReceiver to include the default actions, this way the user can take over control over the actions completely if necessary while maintaining the same defaults.

Alternatives considered

  • I looked at the source code and there is currently no way to work around this because the actions are private final fields and the createPlaybackActions function is static. Additionally, I think this should stay in the constructor.

Thanks for this great lib!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Aug 8, 2019

It’s definitely dismiss-able when paused for me. If you’re setting it as the notification for a foreground service then that might change things because displaying a notification is a requirement for a foreground service (you’d probably need to have the service exit the foreground for it to become dismiss-able again).

We fixed some notification flicker issues in 2.10.0, but they only affected fairly old devices (KitKat), so that’s probably not what you’re seeing.

For documentation, I think any additions would go into https://exoplayer.dev/ui-components.html. Notification manager could be a section similar to the PlayerView and PlayerControlView sections. The ability to override drawables is similar to the ability to override layout files (it’s just a different resource type), and applies to PlayerView and PlayerControlView as well. Documentation goes into the gh-pages branch here. There’s a README.md that points to the resources needed to get started.

0reactions
nomisRevcommented, Sep 15, 2019

Thanks for the quick reply.

That’s great, I already shared my solution in the issue. It’s working very well for me at the moment, and it already works based on existing callbacks provided by ExoPlayer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PlayerNotificationManager (ExoPlayer library)
The actions included in the notification can be customized along with their ... Instead, the large icon is obtained from the PlayerNotificationManager.
Read more >
Change action icon of playerNotificationManager like play ...
You can override the icons used by PlayerNotificationManager by redefining the resources in your app's resources.
Read more >
PlayerNotificationManager | Android Developers
The actions included in the notification can be customized along ... Unlike the drawables above, the large icon (i.e. the icon passed to ......
Read more >
com.google.android.exoplayer2.ui.PlayerNotificationManager ...
Defines and handles custom actions. Most used methods. createCustomActions. Gets the actions handled by this receiver.If multiple PlayerNotificationManager ...
Read more >
PlayerNotificationManager (library-ui API) - javadoc.io
Defines and handles custom actions. static interface, PlayerNotificationManager.MediaDescriptionAdapter. An adapter to provide content assets of the media ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found