jofr / capacitor-media-session

Capacitor plugin for media notifications and platform media keys as well as background audio playback.
GNU General Public License v3.0
33 stars 25 forks source link

Custom logo icon instead of default speaker icon #6

Open AKempente opened 1 year ago

AKempente commented 1 year ago

I love this plugin, after migrating from cordova to capacitor, i confirm this is the best external player for Android and web. I can't comment on iOS as i haven't tried it yet.

One question or maybe feature request would be on how to add custom logo icon instead of the default speaker icon displayed on Android.

Please let me know a suggested way to implement it if possible. I couldn't find any info on the documentation or examples.

Cheerios ;)

jofr commented 1 year ago

Hi, so there is currently no option to change the notification icon on Android but I guess that could be added as an option in the plugin configuration, I'll look into that.

In the meantime: the relevant part of the code that needs to be changed is this line in MediaSessionService.java. If you change this to some other icon (that has been added as a resource to the Android project) then that icon will be used for the media notification on Android.

AKempente commented 1 year ago

@jofr you're a star. the suggested method, changing the icon in MediaSessionService.java has done the job for me.

Thank you

kaaloo commented 1 year ago

How did you go about this @AKempente ? That file is in node_modules which I don't check into git. 🤔

AKempente commented 1 year ago

@kaaloo sorry for the delay in responding, I changed MediaSessionService.java file line (107) in Android Studio:

  1. Open your project in Android Studio
  2. You should see jofr-capacitor-media-session folder
  3. open the java/io.github.jofr.capa...../MediaSessionService
  4. change line 107 to ".setSmallIcon(R.drawable.customicon)"
  5. add the icon (customicon.png) inside jofr-capacitor-media-session.../res/drawable

I hope that helps.

here is the change .setSmallIcon(R.drawable.customicon_24)