Play sound clip from local file in Java

This solution works only for .wav files.

Source code:

public void playSound() {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("D:/MusicPlayer/fml.mp3").getAbsoluteFile());
Clip clip = AudioSystem.getClip();;
} catch(Exception ex) {
System.out.println("Error with playing sound.");

External References

Leave a Reply

Your email address will not be published. Required fields are marked *