How to make a gradual increase in the volume of the track, and a gradual decrease in the volume of the track. The tracks are in Appendix 2, and they are played with crossfade. That is, at the beginning the track should gradually increase in volume, and at the end gradually decrease in volume .... I did it using countDownTimer, but this is not very correct. Can that will advise? I play tracks using MediaPlayer.

    1 answer 1

    audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); //Π£Π²Π΅Π»ΠΈΡ‡Π΅Π½ΠΈΠ΅ громкости audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,AudioManager.FLAG_SHOW_UI); //УмСньшСниС громкости audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); 

    Just add a timer and execute this code on a timer.

    • Thanks for the answer. And if there are several MediaPlayer objects, then how to bind a specific AudioManager to a specific MediaPlayer. - Andrey Timofeev
    • Hmm, to be honest, did not work with this :) You can take a look at the Sound Pool - with its help you can also play media files and even overlay them on each other. - Andrew Tarasenko