How do you change the output volume of a sound?

末鹿安然 提交于 2020-01-25 10:23:09

问题


I'm using this code to play a sound.

I would like to give the user the ability to alter the volume of the sound. Can you tell me how to do this?

NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.sound = Uri.parse("android.resource://emad/raw/quarter");

Thanks.

Truly, Emad


回答1:


use

  notification.audioStreamType = AudioManager.STREAM_MUSIC;

  context.setVolumeControlStream(AudioManager.STREAM_MUSIC);


来源:https://stackoverflow.com/questions/7337481/how-do-you-change-the-output-volume-of-a-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!