Android : How to set MediaPlayer volume programmatically?

后端 未结 10 518
你的背包
你的背包 2020-12-08 04:17

How to set the mediaplayer volume programmatically. I use it for alarm notification. Any help is highly appreciated and thanks in advance.

10条回答
  •  眼角桃花
    2020-12-08 04:52

    To Hide Volume Controll UI:

    audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    

    For Volume UP

    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                        AudioManager.ADJUST_RAISE, 0);
    

    for Volume Down

    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                        AudioManager.ADJUST_LOWER, 0);
    

提交回复
热议问题