Java: Fade out music

2019-07-10 00:26发布

问题:

I'm making a game. Now if my player goes to another level the music is still playing. Now I want to let the music fade out to let start the new music of the next level.

I use mp3 to play. With the packages: jl1.0, mp3spi1.9.4, tritonus_share-0.3.6. Oh yeah. Volume is not supported in the FloatControll class.

回答1:

I suppose you're trying to get Volume control instead of MasterGain. Try this:

if (line.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
    masterGain = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
}