问题
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?
回答1:
I had the same problem and I solved it by putting the following code in my onCreate() function.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
来源:https://stackoverflow.com/questions/28570040/android-mediaplayer-is-paused-volume-buttons-do-not-control-multimedia