xbmc/Kore

[Feature request] Option to disable Media Session Service / change volume only when app in foreground.

baklim opened this issue · 6 comments

Context

I've tried to use kore-20220916-e867841-master.apk on Android 12 and I realy apprecate progress. But one thing that realy annoys me is then I try to change volume ("Use device volume keys" option enabled) in other apps it changes on Kodi first (see pic). You need to drag second volume slider by hand to chnge other apps actual volume.

Possible Implementation

Option to disable Media Session Service or to change volume only when app in foreground.

Additional context, screenshots or links

Here are some relevant links or screenshots:

2022-09-18_16-44

I don't use the hardware volume keys, so i haven't looked into it in detail, but from my tests, Android had come kind of internal rules to choose which app to set the volume when more than one was registered on the media session service. It almost seemed somewhat random, but maybe that was a glitch of the specific Samsung implementation of Android that i tested with.

Anyway, @caffeineFox introduced that, so maybe he has something to contribute to this.

Making it optional is acceptable, but i don't think it should be a new option, it should instead reuse the current "Use device volume keys" option, changing it from being a switch to being a list of options, with something like Off, Always or When in foreground.

It may seem like random behavior/ranking, which app's volume is controlled, but if correctly implemented by all apps, the most recently started media session should get the volume control input from the hardware keys. A list option would sure work, but I'd feel like fixing some other apps issues with a workaround on Kore's side.

Firstly not all apps registers itself as Media Session and those do this (e.g. VLC or NewPipe) respects changing volume in other apss. It's like that recent Kore version always attempts to grab hardware keys.

First of all, showing a notification and registering in the Media Session is absolutely something that Kore or any other media app should do.

Second, apps don't have control over "respect changing volume in other apps", that's Android's responsibility, and regarding "Kore attempts to always grab hardware keys" i would appreciate if you could point out some evidence of that, because that's false.

That tone isn't helping.

Please dont't get me wrong I won' tot be loud - it's only my weak English level. I realy apprecate your work. What kind of evidence do you want? My scenario:

  1. Launch something on Kodi from Kore.
  2. Switch to another app e.g. Telegram.
  3. Attempt to change volume -> volume is changing on Kodi. (I have additional sound bar like at screenshot I've provided earlier)

Ok, i agree that Android's handling of this is kind of confusing, and afaict it depends on the specific android version (and maybe even on the specific manufacturer implementation).

@caffeineFox described what should happen: the key events are routed to the latest media app playing, and that's what appears to be the case most of the time. But it can indeed be confusing if a user simply wants to change the global volume, and Android systematically routes it to the latest media app. But in no situation is Kore "hijacking" the key event - if there's other media app playing last, the key event is routed to that app.

Furthermore, i believe that Google silently changed this in Android 13, as in my current phone, Kore simply doesn't appear when pressing the button...

So, i've decided to expand the "Use hardware volume keys" to include an option "When Kore is in the foreground", so that Kore only responds to the volume keys when in the foreground, and not through the Media Session. It's better to do this now, as it resets the setting for users, and given that the new version resets some other settings, this is just one more that users will need to pay attention to.

Should be merged soon.