Skip to content

Android App Setting the Volume Control Stream

Android has several streams for media playback (e.g. ring tone, notifications, music) which can be controlled independently. This allows you to mute your ring tone while still listening to music or play games with sound. The problem is that sometimes you would like to increase or decrease the volume of one stream but the current stream is set to another one.

For example, in some apps with media content like music you would like to control the volume of the media playback but the current control stream is set to the notification stream or the ringer stream. While the media is playing you can control its volume but as soon as it stops the volume control stream changes to the default stream.

To set the volume control to one stream in your app you have to use the AudioManager:

setVolumeControlStream(AudioManager.STREAM_MUSIC);

This sets the volume control stream to STREAM_MUSIC which is the audio stream for music playback.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*