Victor Grazi
Victor Grazi

Reputation: 16490

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?

Upvotes: 5

Views: 778

Answers (1)

Rafael
Rafael

Reputation: 6709

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

setVolumeControlStream(AudioManager.STREAM_MUSIC);

like described in How to control media volume?

Upvotes: 5

Related Questions