3

I played a sample music (.mp3) using a sample code I found on the Internet. The code is something like

MediaPlayer mp = new ...
mp.setDataSource(...
mp.setAudioStreamType(...
mp.prepare();
mp.start();

The problem is that when the music is paused, the volume buttons do not control multimedia volume but notification volume.

mp.pause();

This behaviour is different from other music players I have tested. Samsung's built-in Music, VLC, and other programs still showed multimedia volume when the music has been paused.

How can I make multimedia volume appear when music is paused?

PS: It seems other players make pressing volume buttons control multimedia volume, no matter what the current playing status is, even playing has not been started at all. How can I do this?

Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135

1 Answers1

3

I had the same problem and I solved it by putting the following code in my onCreate() function.

setVolumeControlStream(AudioManager.STREAM_MUSIC);
inga
  • 3,154
  • 1
  • 25
  • 29