5

I'm using PlayerNotificationManager for displaying playback notifications in my application. Everything is working fine but I want to add my application's logo in the notification with custom fonts.

I changed the play & pause buttons on the notification by adding drawables.xml. But can't find a way to change the font.

So, how can I change the default notification layout and characteristics that Exoplayer provides?

Edit: I have seen this issue on Github which says that we need to extend PlayerNotificationManager in order to use custom layout. But I can't seem to get it working.

Here is my code:

 private void setPlayerNotificationManager(Player player) {


    playerNotificationManager = new PlayerNotificationManager(context, "123", 1234, mediaDescriptionAdapter);
    playerNotificationManager.setUseNavigationActions(false);
    playerNotificationManager.setUsePlayPauseActions(true);
    playerNotificationManager.setRewindIncrementMs(0);
    playerNotificationManager.setFastForwardIncrementMs(0);
    //playerNotificationManager.setColor(Color.GREEN);
    playerNotificationManager.setColorized(true);
    playerNotificationManager.setUseChronometer(false);
    playerNotificationManager.setSmallIcon(R.drawable.logo);
    playerNotificationManager.setPlayer(player);

}
3
  • I've look around in the exoplayer documentation and source but I haven't found anything you could use directly, you should probably ask directly on the repo
    – Biscuit
    Commented Oct 19, 2020 at 8:33
  • Yesterday, I have seen an issue on the repo where it is told that, we have to extend playerNotificationManager class to use custom layout. But I couldn’t get it working. Any ideas on that? Commented Oct 19, 2020 at 8:37
  • @Biscuit Here is the link to the issue on Github: github.com/google/ExoPlayer/issues/7576 Commented Oct 19, 2020 at 8:43

1 Answer 1

4
+50

As said on the repo you need to extends the PlayerNotificationManager to do that you need to create this class and copy everything inside your project, and then add the layout you want to use as described in this link

You need to add your layout in the builder here

5
  • I copied the whole class & made the changes. It's not working. The default notification layout prevails. Any ideas? Commented Oct 19, 2020 at 12:10
  • 1
    Have you changed the import in the file that contains your function setPlayerNotificationManager ? You need to import PlayerNotificationManager from your project and not the one from Exoplayer
    – Biscuit
    Commented Oct 19, 2020 at 12:46
  • Yes, I have changed that. Also registered the Broadcast receiver in my Manifest. It is declared in here: github.com/google/ExoPlayer/blob/release-v2/library/ui/src/main/… Commented Oct 19, 2020 at 12:54
  • Now, my custom layout loads but without any buttons. I don't know how to add that in the layout ( I mean the button id's) Commented Oct 19, 2020 at 12:56
  • 1
    I'm not sure about what you're missing but take a look at that developer.android.com/training/notify-user/… to add button to your layout, basically you need to re-do what Exoplayer was doing for you in the background
    – Biscuit
    Commented Oct 19, 2020 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.