Search code examples
androidchromecastvolume

example code on how to show Chromecast Volume slider with a soft button not physical volume controls


Is there a way to show the volume slider for my chromecast app without having to use the onDispatchKey command? Netflix has a volume icon in their app and when you tap it, it shows the cast volume slider.

I cannot find an example of this anywhere. Only things through remoteControlClient on a lockscreen.

Thanks, Reid


Solution

  • If you want to open the platform's overlay window for changing volume, do the following:

    AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_SAME,
            AudioManager.USE_DEFAULT_STREAM_TYPE, AudioManager.FLAG_SHOW_UI);