javax.sound.sampled cannot change volume of clip

public void play(float volume) {
    try {
        AudioInputStream stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(file));
        DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat());
        Clip clip = (Clip) AudioSystem.getLine(info);
        ((FloatControl) AudioSystem.getMixer(null).getControl(FloatControl.Type.VOLUME)).setValue(volume);
        clip.open(stream);
        clip.start();
    } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
        e.printStackTrace();
    }
}

The method above should play a .wav file at the specified volume (file is a byte[] loaded from the .wav).
However, Java tells me that it's an unsupported control type. I've tried everything and none of it works. Am I just missing something obvious? This is what the oracle site told me to do. I have a windows 11 surface pro 7, and Minecraft can change audio volume, so it's not my device. Help?
Was this page helpful?