Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have volume button control media when media not playing on Android

I am building an audio player, where the audio can be turned on and off. When the audio is on the volume control button on the phone properly controls the media volume.

However when the audio is off, the volume button controls the phone ringer volume.

Is it possible to configure the volume button such that it will control the media volume even when media is not playing?

like image 753
Victor Grazi Avatar asked Mar 14 '12 21:03

Victor Grazi


1 Answers

In your activity's onCreate() you can do:

setVolumeControlStream(AudioManager.STREAM_MUSIC);

like described in How to control media volume?

like image 168
Rafael Avatar answered Sep 20 '22 05:09

Rafael