How to change media volume on Android?

I’m using an HTC Amaze, and depending on what the specific app is doing and when, i can use the hardware volume controls to either control the Ringtone Volume (default), or the Media Volume. Using my cocos2dx project, and changing the volume, only the ringtone volume responds. How can i force the volume controls to be specifically Media volume? Thanks.

Hey guys,
I’m having the same problem. Any ideas how to solve this?

Thanks

Ok, I know what is happening.

If there is some sound playing (like background music) the volume buttons will control the media volume, but when no sound is playing the buttons will control the ringer volume.

If there isnt background music, the buttons only will work if there is some effect sound playing, so it will be strange.

I prefer the buttons always change the media volume. It can be done adding this line to the method onCreate of the main activity :

this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

3 Likes

Thanks for sharing!

@earlsarag
Thanks a lot! :;ok

Thank you! It works!
I think it should be added to android part of engine in case c++ code use any effect (CocosDenshion::SimpleAudioEngine::getInstance() called at least once)

1 Like