Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Control the audio volume which is playing from Service?

My apps playing two audio, first from service and second from activity. I want to decrease the volume of first audio when second audio is playing. After stop the second audio, the volume of first audio should be increases.

like image 438
Android Boy Avatar asked Sep 26 '22 21:09

Android Boy


1 Answers

MediaPlayer has methods for that. It sets volume for left and right channel. Unmuted:

mediaPlayerA.setVolume(1.0f, 1.0f);

mute the other player

mediaPlayerB.setVolume(0.0f, 0.0f);
like image 185
Fred Felsbruckner Avatar answered Sep 30 '22 06:09

Fred Felsbruckner