Bug 404576

Summary: Optionally bind volume keys globally
Product: [Applications] kdeconnect Reporter: rugk <7429c5c9>
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: REPORTED ---    
Severity: wishlist CC: major-mayer
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Android   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Google Cast Volume Slider

Description rugk 2019-02-19 22:00:33 UTC
Currently, only when you press the volume hardware keys when you are in the view of the media control they work and trigger the connected outout device.

Actually, IMHO we can expand this, as I see a common use case:
* you usually want to hear the music you control by yourself, i.e. e.g. have headphones connected to desktop
* you usually also only control one such audio output device (makes sense with first point, as you are unlikely to "mix" it with different devices.)
* also in this case, you obviously do not hear any music on your phone itself, then you would not need KDE Connect

So if:
* only one device is running music
* a special setting is enabled

KDE Connect app should IMHO enable "volume key" overwrite globally.

It would be great to also have that feature on the lock screen, because you can then also control the volume without unlocking your phone. :)
Comment 1 major-mayer 2025-05-20 19:27:00 UTC
Created attachment 181582 [details]
Google Cast Volume Slider

I would also greatly support the implementation of such a feature!
It's a pity that this feature request is open since 2019 without a single response.

6 years later, I think this would work even better with modern Android versions.
For reference, take the example of Google Cast.
If you are casting your content, e.g., Spotify music, to a Google Cast-enabled device, you can control the volume of this device with your hardware keys.
Interestingly, this doesn't only work when the application is open, but also when it's in background or even when the device is locked.

In the screenshot attached, you can see that whenever casting is active, a second volume slider appears, that can be used to control the volume of the connected device, alongside the volume of the smartphone.
The connected device is a part of all other connected devices in the Android system, such as Bluetooth speakers etc.
I am not sure if such functionality is open for non-Google applications as well, but if that's the case, KDE Connect should make use of it, as it would fit perfectly in this category of connected devices.
That would be a great addition IMO.
Comment 2 major-mayer 2025-05-20 20:17:41 UTC
Unfortunately, I am not an Android developer, but I found a discussion that seems to be interesting regarding this use case: https://issuetracker.google.com/issues/201546605

Especially the one quote from a Google dev seems promising: "For Cast-like use cases (but using some other non-Cast protocol, for example DIAL), we would still expect apps to integrate with MediaRouteProvider/MediaRouter, which should be sufficient for volume button clicks to be delivered." (https://issuetracker.google.com/issues/201546605#comment156)

He is probably referring to: https://developer.android.com/media/routing/mediarouteprovider
And I also found this demo project, that seems to be using a different (undocumented) approach: https://github.com/oliverClimbs/VolumeButtonDemo
Request to make this API official: https://issuetracker.google.com/issues/333967641

Maybe also interesting: https://stackoverflow.com/questions/11318933/listen-to-volume-changes-events-on-android

I would really appreciate hearing getting feedback on these approaches.