4

I'm attempting to lower the volume on a Fire TV, but am unable to do so. The following code works on other Android TV devices, except for the Fire TV. I am thinking this may be a disabled feature for FireTV based on this (https://forums.developer.amazon.com/questions/12152/volume-control.html), however, I'm unable to find any official documentation stating as such. Any help would be appreciated. Thanks.

private var userVolume = -1

override fun lowerVolume() {
    (context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager)?.run {
        if (userVolume < 0) {
            userVolume = getStreamVolume(AudioManager.STREAM_MUSIC)
            ValueAnimator.ofInt(userVolume, (.2 * userVolume).toInt()).apply {
                addUpdateListener {
                    setStreamVolume(AudioManager.STREAM_MUSIC, animatedValue as Int, 0)
                }
                duration = 400
            }.start()

        }
    }
}
Reid Mac
  • 2,411
  • 6
  • 37
  • 64

0 Answers0