Android : How to set MediaPlayer volume programmatically?

后端 未结 10 524
你的背包
你的背包 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:30

    Read this page right here. It explains very well. Basically, unless your app is a replacement alarm clock, you need to make the following call in the "onCreate()" function:

    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    

    In this way you can create the volume of your app using the hardware buttons.

提交回复
热议问题