Is it possible to use the media volume button if Android does not play

I create an audio player where the sound can be turned on and off. When the sound on the volume control button on the phone correctly adjusts the volume of the media.

However, when the sound is turned off, the volume button adjusts the volume of the phone ringer.

Is it possible to adjust the volume button so that it controls the volume of the medium even when the medium is not playing?

+4
source share
1 answer

In your onCreate () activity, you can:

setVolumeControlStream(AudioManager.STREAM_MUSIC); 

as described in How to control multimedia volume?

+4
source

Source: https://habr.com/ru/post/1401484/


All Articles