Search code examples
androidvolumegoogle-cast

Cast icon when changing volume via HW buttons


I am developing an application which supports GoogleCast. I am using a CastCompanionLibrary and everything works fine, but there is one little problem there in my application. I need to change the layout, which appears in case that user changes the volume via HW buttons. In my application, there the layout looks like this:

enter image description here

There is a Cast icon in this layout, but it is white and visibility of them is very bad. For example, in YouTube application, there the same layout looks like this:

enter image description here

So, my question is simple: how can I change the layout, or how can I change the Cast icon in layout? I do not see it in CastCompanionLibrary. Thanks for any advice.


Solution

  • As far as I know, the UI that you see there when you change the volume is provided by the system through MediaSession or RemoteControlClient, etc and not the application itself. As a result, I am not aware of any way to change that. The UI that you see in YT is a custom UI, and handling of the volume is done through app; in fact if you send the YT app to background and change the volume, you see a different UI so they seem to have decided to capture hardware volume themselves and provide their own custom UI. This is doable as long as your app is in front; as soon as it loses focus (for example when it goes to background), your app doesn't receive the volume key events and your app cannot do much (that is what happens to YT as well). Try Google Play Music and see how their UI looks like when you change volume while casting.