You donโt know how you executed your MediaPlayer to match your service, but in my test I created an instance of MediaPlayer in my service class. To control the volume of a MediaPlayer instance of a service class, outside its service class, I install the MediaPlayer instance as a static member.
So, in my service class, I did this:
static MediaPlayer mediaPlayer = new MediaPlayer();
In my activity (which has its own sound reproduction), I did this:
MyOwnService.mediaPlayer.setVolume(0.1f, 0.1f);
So, when I jumped into my activity, I first used this expression before playing an audio recording of activity. Notice I did not disable (0.0f, 0.0f). You can play with your floats until it suits your needs. It ranges from 0.0f to 1.0f.
In my work, I also implemented MediaPlayer.OnCompletionListener so that I know when the sound for the Activity was completed. This interface has one implementation method, onCompletion(MediaPlayer mp) . This method is called after the sound ends.
So, in my activity, I also did this:
@Override public void onCompletion(MediaPlayer mp) { MyOwnService.mediaPlayer.setVolume(1.0f, 1.0f); }
Here I raised the volume of official music to max, as now the audio playback in the framework of this activity is completed.
Again, all this was in the test, and I would not want to show the static member in this way (in the published application), I would encapsulate it somehow, so there is some type of access control.
Hope this was helpful.