Change media player volume on seekbar

后端 未结 2 927
你的背包
你的背包 2020-12-22 08:51

I am working on a game application. But there is a problem on volume control. I want to change media player volume using a seekBar, and not system media volume. Is there any

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 09:46

    May be this help...

    protected static void setVolume(int volume) {
            currentVolume = volume;
            {
                if (volume == 1) {
                    volume = 2;
                }
                try {
                    float vol = ((float) volume / CONSTANT.SYSTEM_MAX_VOLUME);
                    mediaPlayer.setVolume(vol, vol);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
    
        }
    

提交回复
热议问题